EDUCATED MONKEY
Board Regular
- Joined
- Jul 17, 2011
- Messages
- 218
Window XP Professional Office 2003 ie8<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o> </o>
<o> </o>
In this project I have a user form, “UserForm1” which initially I start up by using the forms Activate method<o></o>
e.g.<o></o>
<o> </o>
Private Sub Worksheet_Activate()<o></o>
Worksheets("DataInput").Range("A2").Select ‘set active cell on worksheet DataInput<o></o>
UserForm1.Show<o></o>
'Call UserForm_Initialize<o></o>
<o> </o>
End Sub<o></o>
<o> </o>
This works fine except that if I leave the Call UserForm_Initialize in I get run error 424 <o></o>
And this line is .AddItem "GOOD" highlight please see section of code block 1<o></o>
<o> </o>
If however I put the exact same code behind a command button it works fine ? so I know at least that code block 1 works correctly and initialises all the combo boxes as required<o></o>
<o> </o>
Now I move on to the next odd think I need help with, on this same user form I have a button defined as BtnPreviousRecord the required action here being to load the values on a particular row on the DataInput worksheet again if I put the code behind the command button to do so it works fine, however if I put the exact same code in a macro and try to call the macro by clicking the button I get run error 424 please see code block 2<o></o>
<o> </o>
I am assuming that I calling these macros incorrectly or something along those lines so please if you can tell what the calling conventions are <o></o>
<o> </o>
<o> </o>
In this project I have a user form, “UserForm1” which initially I start up by using the forms Activate method<o></o>
e.g.<o></o>
<o> </o>
Private Sub Worksheet_Activate()<o></o>
Worksheets("DataInput").Range("A2").Select ‘set active cell on worksheet DataInput<o></o>
UserForm1.Show<o></o>
'Call UserForm_Initialize<o></o>
<o> </o>
End Sub<o></o>
<o> </o>
This works fine except that if I leave the Call UserForm_Initialize in I get run error 424 <o></o>
And this line is .AddItem "GOOD" highlight please see section of code block 1<o></o>
<o> </o>
If however I put the exact same code behind a command button it works fine ? so I know at least that code block 1 works correctly and initialises all the combo boxes as required<o></o>
<o> </o>
Now I move on to the next odd think I need help with, on this same user form I have a button defined as BtnPreviousRecord the required action here being to load the values on a particular row on the DataInput worksheet again if I put the code behind the command button to do so it works fine, however if I put the exact same code in a macro and try to call the macro by clicking the button I get run error 424 please see code block 2<o></o>
<o> </o>
I am assuming that I calling these macros incorrectly or something along those lines so please if you can tell what the calling conventions are <o></o>
Rich (BB code):
code block 1 part of <o:p></o:p>
<o:p> </o:p>
Sub UserForm_Initialize()<o:p></o:p>
'<o:p></o:p>
' FillComboBox Macro<o:p></o:p>
' Macro recorded <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:date Month="9" Day="7" Year="2011">07/09/2011</st1:date> by development2<o:p></o:p>
'<o:p></o:p>
' Keyboard Shortcut: Ctrl+Shift+F<o:p></o:p>
'<o:p></o:p>
With cbogc ' Add values to combo box general condition<o:p></o:p>
.AddItem "GOOD"<o:p></o:p>
.AddItem "FAIR"<o:p></o:p>
End With<o:p></o:p>
<o:p> </o:p>
End Sub
Rich (BB code):
code block 2<o:p></o:p>
<o:p> </o:p>
Private Sub BtnPreviousRecord_Click()<o:p></o:p>
Dim LValue2 As String<o:p></o:p>
'need to add the no jpeg rootine<o:p></o:p>
Dim LValue3 As String<o:p></o:p>
Dim LValue4 As String<o:p></o:p>
Dim LValue5 As String<o:p></o:p>
Dim MyString As String<o:p></o:p>
Dim NewString As String<o:p></o:p>
Dim MyString2 As String<o:p></o:p>
Dim MyString1 As String<o:p></o:p>
Worksheets("DataInput").Range("A2").Select<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
TextBox13DIGIT_ISBN.Value = ActiveCell.Value<o:p></o:p>
TextBox13DIGIT_ISBN_HY.Value = ActiveCell.Offset(0, 1)<o:p></o:p>
TextBox10DIGIT_ISBN.Value = ActiveCell.Offset(0, 2)<o:p></o:p>
TextBox10DIGIT_ISBN_HY.Value = ActiveCell.Offset(0, 3)<o:p></o:p>
TextBoxNAME_1.Value = ActiveCell.Offset(0, 4)<o:p></o:p>
'TextBoxNAME_I.Value = ActiveCell.Offset(0, 5)<o:p></o:p>
TextBoxNAME_2.Value = ActiveCell.Offset(0, 5)<o:p></o:p>
TextBoxTITLE.Value = ActiveCell.Offset(0, 6)<o:p></o:p>
TextBoxHEIGHT.Value = ActiveCell.Offset(0, 7)<o:p></o:p>
TextBoxWIDTH.Value = ActiveCell.Offset(0, 8)<o:p></o:p>
TextBoxDEPTH.Value = ActiveCell.Offset(0, 9)<o:p></o:p>
TextBoxWEIGHT.Value = ActiveCell.Offset(0, 10)<o:p></o:p>
TextBoxYEAR.Value = ActiveCell.Offset(0, 11)<o:p></o:p>
TextBoxEDITION.Value = ActiveCell.Offset(0, 13)<o:p></o:p>
TextBoxPUBLISHER.Value = ActiveCell.Offset(0, 14)<o:p></o:p>
TextBoxFORMAT.Value = ActiveCell.Offset(0, 21)<o:p></o:p>
TextBoxBookType.Value = ActiveCell.Offset(0, 17)<o:p></o:p>
TextBoxCost.Value = ActiveCell.Offset(0, 12)<o:p></o:p>
TextBoxlocation.Value = ActiveCell.Offset(0, 20)<o:p></o:p>
TextBoxJpeg.Value = ActiveCell.Offset(0, 22)<o:p></o:p>
cbogc.Value = ActiveCell.Offset(0, 18)<o:p></o:p>
cboGENRE.Value = ActiveCell.Offset(0, 16)<o:p></o:p>
ComboBoxAdditional.Value = ActiveCell.Offset(0, 17)<o:p></o:p>
TextBoxSYNOPSIS.Value = ActiveCell.Offset(0, 15)<o:p></o:p>
MyString = ".jpg"<o:p></o:p>
MyString1 = ActiveCell.Offset(0, 4).Value<o:p></o:p>
MyString2 = ActiveCell.Offset(0, 5).Value<o:p></o:p>
NewString = MyString1 & " " & MyString2<o:p></o:p>
LValue5 = LCase(NewString)<o:p></o:p>
LValue3 = ActiveCell.Offset(0, 22).Value<o:p></o:p>
<o:p> </o:p>
LValue2 = "I:\PICTURES OF BOOKS\" & LValue3 & MyString<o:p></o:p>
<o:p> </o:p>
Image1.Picture = LoadPicture(LValue2)<o:p></o:p>
LValue4 = "I:\authorpics\" & LValue5 & MyString<o:p></o:p>
<o:p> </o:p>
If Len(Dir(LValue4)) Then 'check to see if there is a jpeg<o:p></o:p>
Image2.Picture = LoadPicture(LValue4)<o:p></o:p>
End If<o:p></o:p>
<o:p> </o:p>
'Call GetData<o:p></o:p>
<o:p> </o:p>
End Sub<o:p></o:p>