Problem with Inputbox

Mansoor Ahmad

Registered User.
Local time
Today, 16:58
Joined
Jan 20, 2003
Messages
140
Dear All

Here is a full code that I am using and I am sure I have messed it up a lot since this morning.

The way I want it to work is that on click of a button, it asks user to input data and then filter the records for this data and opens in form view.

In this condition it does open the form but does not filter the records

Can somebody please look at it and tell me where I am wrong?

Thanks


Public Function GetData(strMessage As String) As String
InputBox strMessage, "Result"
End Function



Private Sub Cmdformview_Click()
Call formview("F_Formview")
End Sub



Private Sub formview(frmName As String)
Dim stwhere As String
Dim myInt As String

myInt = GetData("GIVE WR NO")

stwhere = "[WR LABEL] = '" & myInt & "'"

Call OpenForm(frmName, stwhere)
End sub



Public Function OpenForm(frmName As String, stwhere As String)
DoCmd.OpenForm (frmName), acNormal, , stwhere
End Function
 
The problem lies with your GetData function. You are calling the Inputbox, but not in a way that passes the value back to GetData. Try this modification:
Code:
Public Function GetData(strMessage As String) As String
    GetData = InputBox(strMessage, "Result")
End Function
 
Thank you very much for your reply. It is working ok now except for one problem.

When Input Box appears and you click on Cancel, it still opens the form. How can I change it so that by clicking on Cancel, it would stop there?
Thanks in advance.
 
Just to let you know that I have managed to solve the problem.

I have changed the statements in Private sub formview to following and it is working just fine. If you have got any better suggestion please let me know?

Private Sub formview(frmName As String)

myInt = GetData("Give WR label No")
If myInt <> "" Then
stwhere = "[WR LABEL] = '" & myInt & "'"
Call OpenForm(frmName, stwhere)
End If
End sub


Thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom