O
Orv
I have placed a command button on a form, that when clicked prompts for a
number, then should goto that record. Here is my code:
Command Button on click: =OpenFormWithInput()
Code:
Option Explicit
Function OpenFormWithInput()
Dim Msg As String
Dim Title As String
Dim Answer As String
Msg = "Enter RTF Number (11111.)."
Title = "OPEN RTF FORM"
Answer = InputBox(Msg, Title)
If Answer <> "" Then
DoCmd.OpenForm "frmRTF", , "[RTFNumber]='" & Answer & "' "
Else
DoCmd.OpenForm "frmRTF"
End If
End Function
When I open the form and click on the button, I enter a number (with or w/o
the hyphen) in the prompt and click OK, it then goes to the first record,
regardless of the nuber entered.
The RTFNumber field is formatted as 00-0000 and has input mask as such
99\-9999 not that I think this matters. I think there is an error in my code
more particulary with the DoCmd OpenForm.
Any help is appreciated,
Orv
number, then should goto that record. Here is my code:
Command Button on click: =OpenFormWithInput()
Code:
Option Explicit
Function OpenFormWithInput()
Dim Msg As String
Dim Title As String
Dim Answer As String
Msg = "Enter RTF Number (11111.)."
Title = "OPEN RTF FORM"
Answer = InputBox(Msg, Title)
If Answer <> "" Then
DoCmd.OpenForm "frmRTF", , "[RTFNumber]='" & Answer & "' "
Else
DoCmd.OpenForm "frmRTF"
End If
End Function
When I open the form and click on the button, I enter a number (with or w/o
the hyphen) in the prompt and click OK, it then goes to the first record,
regardless of the nuber entered.
The RTFNumber field is formatted as 00-0000 and has input mask as such
99\-9999 not that I think this matters. I think there is an error in my code
more particulary with the DoCmd OpenForm.
Any help is appreciated,
Orv