View Full Version : FindRecord with inputbox


VTG
04-15-2008, 07:44 AM
hi, i am doing an a-level computing project on an order system.
I am having problems searching for a record (by its OrderID) when using the FindRecord function with an inputbox
what i want to do is:
- From a main switchboard, a user clicks on a button that opens up an order form (named 'frmOrder2'), an input box then pops up and asks the user to input the OrderID value (which is numerical). The system then searches through the table 'tblOrder' and shows everything concerning about the order on the order form

i've attempted using this code for the button that opens up the order form and i get this error message 'A macro set to one of the current field's properties failed because of an error in a FindRecord action argument.':

Dim Search As String
Search = InputBox("Please enter the OrderID","OrderSearch")
DoCmd.OpenForm "frmOrder2", acNormal
DoCmd.FindRecord "[OrderID] =" & Search, acEntire, False, acSearchAll, , acCurrent, True

help would be greatly appreciated

ajetrumpet
04-15-2008, 09:36 PM
Dim Search As String
Search = InputBox("Please enter the OrderID","OrderSearch")
DoCmd.OpenForm "frmOrder2", acNormal
DoCmd.FindRecord "[OrderID] =" & Search, acEntire, False, acSearchAll, , acCurrent, TrueThe highlighted syntax is probably in error. You have concatenated the variable outside the quote marks even though it is declared as a string. I would first try putting the variable inside the quote marks and see if that eliminates the message.

Second, the findrecord action in VBA just locates the record internally. It doesn't display anything on the form. To get the information to show up, you have to use the gotorecord action instead.