Open Form to Record requested by MsgBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to open a form to a certin record (using OrderNumber) that is enter
into a inputbox by customer. I keep getting an Error msg saying I cannot do
this. Why?
 
You're going to have to provide more information if you expect anyone to
provide meaningful help. All we can do at this point is guess. Start by
showing the code that you are using. Note that the InputBox function returns
a string value. Is your OrderNumber numeric (for example, an autonumber
datatype or long integer)? If this is the case, then you'll need to use a
type conversion function to convert the string. For example:

lngOrderNumber = CLng(InputBox(Message, Title))

Here is an example that might work for you. If not, then post back with more
details.

'*******************Begin Code*************************
Option Compare Database
Option Explicit

Private Sub cmdOK_Click()
On Error GoTo ProcError

Dim strMessage As String
Dim strTitle As String
Dim lngOrderNumber As Long

strMessage = "Enter Order ID: "
strTitle = "Open Form to Specified Order..."

lngOrderNumber = CLng(InputBox(strMessage, strTitle))

DoCmd.OpenForm "YourFormName", _
WhereCondition:="OrderNumber = " & lngOrderNumber


ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure cmdOK_Click..."
Resume ExitProc
End Sub

'*******************End Code***************************


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

I want to open a form to a certin record (using OrderNumber) that is enter
into a inputbox by customer. I keep getting an Error msg saying I cannot do
this. Why?
 
I forgot the InputBox function returned a string value. It works great.
Thanks for your help Tom.
 
You're welcome. Glad it worked for you.

Tom
________________________________________

:

I forgot the InputBox function returned a string value. It works great.
Thanks for your help Tom.
 
Back
Top