W
wolfiewoman
I'm trying to do search on a form. I type in the course number then hit find
next. I get the error message compile error: Invalid use of property and it
is highlighting .value on the line that says CourseNumber.Value. Can anyone
please assist? I try commenting it to see what happens and I get a popup box
asking me to enter the course number after I have already typed it in the
text box beside the button. If I don't type anything in the popup it comes
up saying run-time error 2109, there is no field named 'CourseNumber' in the
current record. Can someone please assist?
Private Sub findnext_Click()
Dim strCourseRef As String
Dim strCrs As String
'Check txtcrs for Null value or Nill Entry first.
'Or (Me![txtcrs]) = ""
If IsNull(Me![txtcrs]) Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![txtcrs].SetFocus
Exit Sub
End If
'---------------------------------------------------------------
'Performs the search using value entered into txtcrs
'and evaluates this against values in Course Number
DoCmd.ShowAllRecords
DoCmd.GoToControl ("CourseNumber")
DoCmd.FindRecord Me!txtcrs
CourseNumber.Value
strCourseRef = CourseNumber.Value
txtcrs.SetFocus
strCrs = txtcrs.Text
'If matching record found sets focus in Course Number and shows msgbox
'and clears search control
If strCourseRef = strCrs Then
MsgBox "Match Found For: " & strCrs, , "Congratulations!"
CourseNumber.Value
txtcrs = ""
'If value not found sets focus back to txtcrs and shows msgbox
Else
MsgBox "Match Not Found For: " & strCrs & " - Please Try Again.", _
, "Invalid Search Criterion!"
txtcrs.SetFocus
End If
End Sub
next. I get the error message compile error: Invalid use of property and it
is highlighting .value on the line that says CourseNumber.Value. Can anyone
please assist? I try commenting it to see what happens and I get a popup box
asking me to enter the course number after I have already typed it in the
text box beside the button. If I don't type anything in the popup it comes
up saying run-time error 2109, there is no field named 'CourseNumber' in the
current record. Can someone please assist?
Private Sub findnext_Click()
Dim strCourseRef As String
Dim strCrs As String
'Check txtcrs for Null value or Nill Entry first.
'Or (Me![txtcrs]) = ""
If IsNull(Me![txtcrs]) Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![txtcrs].SetFocus
Exit Sub
End If
'---------------------------------------------------------------
'Performs the search using value entered into txtcrs
'and evaluates this against values in Course Number
DoCmd.ShowAllRecords
DoCmd.GoToControl ("CourseNumber")
DoCmd.FindRecord Me!txtcrs
CourseNumber.Value
strCourseRef = CourseNumber.Value
txtcrs.SetFocus
strCrs = txtcrs.Text
'If matching record found sets focus in Course Number and shows msgbox
'and clears search control
If strCourseRef = strCrs Then
MsgBox "Match Found For: " & strCrs, , "Congratulations!"
CourseNumber.Value
txtcrs = ""
'If value not found sets focus back to txtcrs and shows msgbox
Else
MsgBox "Match Not Found For: " & strCrs & " - Please Try Again.", _
, "Invalid Search Criterion!"
txtcrs.SetFocus
End If
End Sub