Solved combo box to select data for report (1 Viewer)

angekap

New member
Local time
Tomorrow, 01:52
Joined
Mar 16, 2021
Messages
12
Hi Everyone,

I was wondering if anyone can help me with a problem I am having.

I have a query which calculates for my suppliers their balance with debit and credit fields from a table called TRANSACTIONS. The query is called TRANSSUP

I have made a form with a ComboBox (named SELSUP) selecting the SUPPLIERS. I have also made a report based on the query called TRANSSUPREPORT which shows all the suppliers with debit, credit and balance fields.

I have also setup a button with the following event proceedure which would filter out the records only based on my combobox for suppliers. The Code is as below:

I have added code tags to properly to display your code. Please use code tags as it makes the code much easier to read. UG

Code:
Private Sub cmdOpenReport_Click()
On Error GoTo Err_Process
   
    If (Not IsNull(Me.SELSUP)) Then
        DoCmd.OpenReport "TRANSSUPREPORT", acViewPreview, , "[SUPPLIER]=" & Me.SELSUP
        
    Else
        MsgBox "You must select an account." & vbCrLf & vbCrLf & "Please try again.", vbExclamation, "No Account Selected"
    End If

Exit_Process:
    Exit Sub
Err_Process:
    MsgBox "Procedure: cmdOpenReport" & vbCrLf & vbCrLf & Err.Number & " " & Err.Description, vbExclamation, "Error"
    Resume Exit_Process
   
End Sub

However when I press the Button a Pop Up Box appears
Screen1.jpg



where the name of the selected from the combo box supplier appears. When I enter the name of the supplier in the pop up box the report shows correctly the report with the selected supplier. I don't want the pop up box to appear, I just want the report to appear right after I click the button.

Anyone who can help will be much appreciated !! Thanks !!!
 
Last edited by a moderator:

Ranman256

Well-known member
Local time
Today, 18:52
Joined
Apr 9, 2015
Messages
4,339
the query is looking for the GALATHRIS field.
if this is not a field, you must alter your query.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 15:52
Joined
Aug 30, 2003
Messages
36,124
Try

DoCmd.OpenReport "TRANSSUPREPORT", acViewPreview, , "[SUPPLIER]='" & Me.SELSUP & "'"

See this for more info:

 

Users who are viewing this thread

Top Bottom