Multiple Value Input Box (1 Viewer)

SkyCraw

Registered User.
Local time
Today, 12:02
Joined
Oct 9, 2013
Messages
100
Good afternoon (for those in the Atlantic Time Zone),

This is more of a curiosity, so if it's not possible it's not the end of the world...

I was wondering how I could do a multiple value InputBox in VBA, if this is even possible... This is so I can prompt the end user to enter a range (with two string values as start and end parameters) for a report I'm working on.

If this is possible, I would like to include this as an additional parameter option within the code I have below (which is working great thus far):

Code:
Private Sub EmployeesBadges_Click()

    Dim soa As Byte
    Dim emp, sEB As String
    
    soa = MsgBox("Do you wish to print a single employee badge or all?", vbYesNo + vbQuestion)
    
    Select Case soa
        Case vbYes
            emp = InputBox("Enter Employee#", "Employee Badges")
            sEB = "SELECT * FROM [Employees] " _
                    & " WHERE [Emp#] = " & emp & ""
            DoCmd.OpenReport "Employee Badges", acViewDesign
            Reports![Employee Badges].RecordSource = sEB
            DoCmd.Close acReport, "Employee Badges", acSaveYes
            DoCmd.OpenReport "Employee Badges", acViewPreview
        Case vbNo
            sEB = "SELECT * from Employees"
            DoCmd.OpenReport "Employee Badges", acViewDesign
            Reports![Employee Badges].RecordSource = sEB
            DoCmd.Close acReport, "Employee Badges", acSaveYes
            DoCmd.OpenReport "Employee Badges", acViewPreview
    End Select
    
End Sub

Like I said, if not possible then no worries... I'll just create a form to do this.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 08:02
Joined
Aug 30, 2003
Messages
36,124
For starters, tweaking your code to use this method:

http://www.baldyweb.com/wherecondition.htm

would be more efficient than opening/closing the report to set its source. As to your question, I personally would use a form anyway, as I feel I have more control. You could do what you're describing with an InputBox by perhaps having the user enter the starting and ending values with a space or dash between and testing the result for that space or dash.
 

SkyCraw

Registered User.
Local time
Today, 12:02
Joined
Oct 9, 2013
Messages
100
Thanks for the tip, pbaldy! I was actually trying to do just that with the OpenForm statement within another database. That link will definitely be referenced a lot! :)
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 08:02
Joined
Aug 30, 2003
Messages
36,124
Happy to help!
 

Users who are viewing this thread

Top Bottom