Whats wrong with this code - Please!!!

de049

Registered User.
Local time
Today, 23:43
Joined
Sep 24, 2001
Messages
18
Can someone please tell me why i always get a Compile Error when i try to enter seaarch criteria in my search textbox. It was working perfectly, then all of a sudden, it gives me this error each time. Also when i press the Refresh button. Both the search textbox and the button refer to a listbox that contains all of my records. The Compiler error is "Method or Data member not found".

Here is the code that is highlted by the debugger (In red):

Private Sub ClearIt_Click()
On Error GoTo Err_ClearIt

Me.Search = ""
Me.Search2 = ""
Me.QuickSearch.Requery
Me.QuickSearch.SetFocus

Exit_ClearIt_Click:
Exit Sub

Err_ClearIt:
MsgBox Err.Description
Resume Exit_ClearIt_Click

End Sub


Private Sub Search_Change()
Dim vSearchString As String

vSearchString = Search.Text
Me.Search2.Value = vSearchString
Me.QuickSearch.Requery

End Sub


Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, 5, acMenuVer70

'The following refreshes the listbox
Me.Search = ""
Me.Search2 = ""
Me.QuickSearch.Requery
Me.QuickSearch.SetFocus

Exit_cmdSave_Click:
Exit Sub


Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click

End Sub
 
"Method or Data member not found".

Always means that in reference X.Y, element Y (whatever it is) does not exist in object X.

Check spelling. Check for possible name conflicts. ALSO check for the outside chance that there is an ambiguity (though I would expect to see a different error message in that case) for element Y.
 
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, 5, acMenuVer70

That's line is also defunct.

Replace it with:
Code:
DoCmd.SaveRecord
 
But why would the search work perfectly and only stop working when I have changed the listbox properties and added some command buttons. The actual code that represents the search has not been altered.

I'm really puzzled now, and its not allowing me to hand in the DB as complete due to this, despite all the hours I've spent on it :( Please help someone....
 
Your db may have become corrupted. Compact and repair. If that doesn't fix the problem. Create a new db and import all objects.

BTW - DoCmd.saverecord doesn't exist. The command is:

DoCmd.RunCommand acCmdSaveRecord
 

Users who are viewing this thread

Back
Top Bottom