JoeyGaspard
Board Regular
- Joined
- Jul 22, 2019
- Messages
- 164
I have created a couple of user forms in vba, they work fine until I click anywhere in the user form that is NOT a field, when I click outside of a field, I get the following error:
Compile error, Sub or Function not defined. Again, this only happens when I click inside the userform, but not in one of the fields, my code is below. Thanks in advance for any help!
Compile error, Sub or Function not defined. Again, this only happens when I click inside the userform, but not in one of the fields, my code is below. Thanks in advance for any help!
Code:
Private Sub UserForm_Activate()
Me.txtDay.Value = Format(Now(), "MM/DD/YYYY")
End Sub
Private Sub txtMachine_Change()
End Sub
Private Sub UserForm_Click()
Begin EggProdData
Me.txtDay.Value = Format(Now(), "MM/DD/YYYY")
Caption = "Data Entry"
ClientHeight = 6360
ClientLeft = 45
ClientTop = 375
ClientWidth = 7770
OleObjectBlob = "EggProdData.frx":
StartUpPosition = 1 'CenterOwner
End Sub
Private Sub cboGrower_DropButt*******()
'Populate control.
Me.cboGrower.AddItem "CW1 4004"
Me.cboGrower.AddItem "CW1 4005"
Me.cboGrower.AddItem "CW2 4020"
Me.cboGrower.AddItem "CW2 4021"
Me.cboGrower.AddItem "CG1 4024"
Me.cboGrower.AddItem "CG1 4025"
Me.cboGrower.AddItem "CG2 4026"
Me.cboGrower.AddItem "CG2 4027"
Me.cboGrower.AddItem "3R1 4032"
Me.cboGrower.AddItem "3R1 4033"
Me.cboGrower.AddItem "3R2 4034"
Me.cboGrower.AddItem "3R2 4035"
Me.cboGrower.AddItem "RM 4036"
Me.cboGrower.AddItem "RM 4037"
Me.cboGrower.AddItem "CLD 4038"
Me.cboGrower.AddItem "CLD 4039"
Me.cboGrower.AddItem "HICO1 4040"
Me.cboGrower.AddItem "HICO1 4041"
Me.cboGrower.AddItem "HICO2 4042"
Me.cboGrower.AddItem "HICO2 4043"
End Sub
Private Sub cboWeek_DropButt*******()
'Populate control.
Me.cboWeek.AddItem "1"
Me.cboWeek.AddItem "2"
Me.cboWeek.AddItem "3"
Me.cboWeek.AddItem "4"
Me.cboWeek.AddItem "5"
End Sub
Private Sub cmdAdd_Click()
'Copy input values to sheet.
Dim lRow As Long
Dim ws As Worksheet
Set ws = Worksheets("LiveData")
lRow = ws.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 2).Value = Me.cboGrower.Value
.Cells(lRow, 3).Value = Me.cboWeek.Value
.Cells(lRow, 4).Value = Me.txtDay.Value
.Cells(lRow, 5).Value = Me.txtMachine.Value
.Cells(lRow, 6).Value = Me.txtEggsSet.Value
.Cells(lRow, 7).Value = Me.txtHatch.Value
End With
'Clear input controls.
Me.cboGrower.Value = ""
Me.cboWeek.Value = ""
Me.txtMachine.Value = ""
Me.txtEggsSet.Value = ""
Me.txtHatch.Value = ""
End Sub
Private Sub cmdClose_Click()
'Close UserForm.
Unload Me
End Sub
Last edited by a moderator: