I’m working on a project in ms access 2007 that involves a main form and subform. The main form contains a record search textbook (txtFind) . I’m trying to search a record contained in the subform from the textbox on the main form, but keep getting the following error message: Run-time error 3024: Could not find file.
Main form is name: As_Designed_Room - Subform name: Avail_Plans_Subform
I checked in the ODBC user DSN, and the database is there. But I still get the error message. Here’s the code I’m working with and it works just fine with my other database projects.
Dim dbs As Database, rst As Recordset
Me.txtFind.SetFocus
If Me.txtFind.Text = "" Then
MsgBox "Contract Number", vbOKOnly, "CODE NUMBER ERROR"
Me.txtFind.SetFocus
Exit Sub
End If
This portion of the code is where error message appears >>> Set dbs = OpenDatabase("File_Room_Plans.mdb")
DoCmd.ShowAllRecords
Set rst = dbs.OpenRecordset("Select Contract_Num From Avail_Plans " & " Where Contract_Num Like " & "'*" & Me.txtFind & "*'" & ";")
If rst.RecordCount < 1 Then
MsgBox "Contract Num not in database", vbOKOnly
End If
I’ve also tried using DLookup, but can’t get that to work either. One more thing, the contract number is alphanumeric (example: B-99999). Not sure what wild cards to use.
Any assistance would be greatly appreciated and thanks in advance.
Main form is name: As_Designed_Room - Subform name: Avail_Plans_Subform
I checked in the ODBC user DSN, and the database is there. But I still get the error message. Here’s the code I’m working with and it works just fine with my other database projects.
Dim dbs As Database, rst As Recordset
Me.txtFind.SetFocus
If Me.txtFind.Text = "" Then
MsgBox "Contract Number", vbOKOnly, "CODE NUMBER ERROR"
Me.txtFind.SetFocus
Exit Sub
End If
This portion of the code is where error message appears >>> Set dbs = OpenDatabase("File_Room_Plans.mdb")
DoCmd.ShowAllRecords
Set rst = dbs.OpenRecordset("Select Contract_Num From Avail_Plans " & " Where Contract_Num Like " & "'*" & Me.txtFind & "*'" & ";")
If rst.RecordCount < 1 Then
MsgBox "Contract Num not in database", vbOKOnly
End If
I’ve also tried using DLookup, but can’t get that to work either. One more thing, the contract number is alphanumeric (example: B-99999). Not sure what wild cards to use.
Any assistance would be greatly appreciated and thanks in advance.