Query Button

GregSmith

Registered User.
Local time
Today, 14:51
Joined
Feb 22, 2002
Messages
126
I have a button on my form that when you press it I want it to ask what Field ID's do you want to view. Right now, it opens them all. Here is the procedure code I am using...

I would like to add to this code and not add it to my query table...

Private Sub Command111_Click()
On Error GoTo Err_Command111_Click

Dim stDocName As String
Rem Between [Enter Beginning ID:] And [Enter Ending ID:]
stDocName = "Tape Log"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_Command111_Click:
Exit Sub

Err_Command111_Click:
MsgBox Err.Description
Resume Exit_Command111_Click

End Sub
 
On your form put two unbound text boxes called BeginID and EndID. In your query in the the Criteria line of the ID field put code like this:

Between [Forms]![YourFormName]![BeginID] And [Forms]![YourFormName]![EndID]

The code in the On Click event of the command button should look like this:

Private Sub Command111_Click()
On Error GoTo Err_Command111_Click

DoCmd.OpenQuery "Tape Log", acNormal, acEdit

Exit_Command111_Click:
Exit Sub

Err_Command111_Click:
MsgBox Err.Description
Resume Exit_Command111_Click

End Sub

The user enters the ID's they want in the 2 fields on the form before the click the command button.


[This message has been edited by Jack Cowley (edited 04-12-2002).]
 

Users who are viewing this thread

Back
Top Bottom