L
Legacy 93538
Guest
Hi
I am trying to build a bit of code which will search and go to a record in the form Boxes. It shoudl first check to see if the number is valid in the table and then go to that record in the form.
However I can not seem to figure how to get it to go to the correct record number. So far I have the following code:
However When I run this code it produces an error when it gets to the line highlighted. it produces the error "Run-time error '2498': An expression you entered is the wrong data type for one of the arguments"
Does anyone know how to make it so the code goes to correct record in the form?
Thanks
Jessicaseymour
I am trying to build a bit of code which will search and go to a record in the form Boxes. It shoudl first check to see if the number is valid in the table and then go to that record in the form.
However I can not seem to figure how to get it to go to the correct record number. So far I have the following code:
Code:
<code>Dim Ref As Integer Dim strSQL As Integer Dim stWhereStr As String Set db = CurrentDb() Ref = Me.Text4.Value stWhereStr = "[Box Number] = " & Ref strSQL = DCount("Box Number", "Boxes", "Box Number = " & ) If strSQL = 0 Then MsgBox "This is box number does not exist. Please try again." Else DoCmd.OpenForm "Boxes", acViewNormal [COLOR=#ff0000]DoCmd.GoToRecord acDataForm, "Boxes", acGoTo, [/COLOR]</code>[COLOR=#ff0000]<code>stWhereStr</code>[/COLOR]<code> DoCmd.Close acForm, "Box Search", acSavePrompt End If</code></pre>
However When I run this code it produces an error when it gets to the line highlighted. it produces the error "Run-time error '2498': An expression you entered is the wrong data type for one of the arguments"
Does anyone know how to make it so the code goes to correct record in the form?
Thanks
Jessicaseymour