Hi there,
You were trying to set Opportunity to the value of a combobox before validating the combobox. You need to check for null first and then set Opportunity.
-
Private Sub Command0_Click()
-
-
Dim Opportunity As String
-
-
Dim message As String
-
-
Me.cmbTeaching.SetFocus
-
-
'Check if a teaching opportunity was selected; if not, ask the user to select one
-
-
If IsNull(Me.cmbTeaching) Then
-
-
MsgBox ("Please select an Opportunity")
-
-
Exit Sub
-
-
Else
-
-
Opportunity = Me.cmbTeaching.Value
-
-
End If
-
I changed my code to that and it threw a different error. "the expression On Click you entered as the event property setting produced the following error: Method or data member not found.
Visual Basic for Applications (VBA) encountered a problem while attempting to access a property or method. The problem may be one of the following:
A reference is missing.
For help restoring missing references, see the Microsoft Knowledge Base article 283806.
An Expression is misspelled.
Check all expressions used in event properties for correct spelling.
A user-defined function is declared as a sub or as a private function in a module.
Expressions can resolve a user-defined function only if the function is declared as one of the following:
A public function in a module
A public or private function in a code module of the current form or report
Security in Access is set to Medium or High and the Microsoft Jet 4.0 SP8 update is not installed.
A more recent verion of Jet 4.0 must be installed for Access to function properly when security is set to Medium or High. To obtain the latest version of Microsoft Jet, go to Windows Update.