Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query by type 2

Status
Not open for further replies.

ailyn

Programmer
Joined
Sep 15, 2005
Messages
108
Location
BE
I have a table products that has a typeId joined to table types. Now I want to make a query that in the form displays the types and by chosing one it displays all the items available of that type.
I'm very newbie to Access queries and all my tries didn't work (by the way the official site doesn't really help);
 
to create an event procedure you have to click the ellipsis (...) in the Onevent property.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Dhookom, i tried your code again and it's the same error still. about compiling I don't have any idea how to, although if you mean clicking the play button for testing the code I did and it gives me the same error once again. I bet that it's going to be a little stupid error but I can't get it. Is there a way to attach the form to the forum or an image of the error (prtScr)?

I also tried the onevent property, instead of cmdOpenRpt_click I tried cmdOpenRpt_Enter. Same error as before.
#sigh# It's so frustrating when it doesn't work.
 
When you attempt to compile the code, it should highlight the line of code in error. What line is highlighted? Is your command button named "cmdOpenRpt"?

When your cursor is in the openreport code area, what do you see in the two dropdowns above the module window? These are the "Object" and "Procedure" lists.

Can you copy and paste all the code from your form's module into a reply?

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
The part highlighted in yellow is the first line where the sub starts. as I don't understand much, because it asked me a name, I put (Cancel as Integer) in "Private Sub cmdOpenRpt_Click(Cancel As Integer)" & then I got another error that says that the expression I used doesn't have the name of a macro, a function or an event procedure. This is the full code in the module of the form:

Option Compare Database

Private Sub cmdOpenRpt_Click()
On Error GoTo Err_cmdOpenRpt_Click
Dim strWhere As String
If Not IsNull(Me.cboTypeId) Then
strWhere = "[TypeId] = " & Me.cboTypeId
End If
Dim stDocName As String
stDocName = "Products"
MsgBox "strWhere: " & strWhere
DoCmd.OpenReport stDocName, acPreview, , strWhere

Exit_cmdOpenRpt_Click:
End Sub

Err_cmdOpenRpt_Click:
Select Case Err
Case 2501
'ignore
Case Else
MsgBox Err.Description
End Select
Resume Exit_cmdOpenRpt_Click
End Sub
 
That will teach me to not copy someone's initial code without reviewing it thoroughly. Try this:
Code:
Private Sub cmdOpenRpt_Click()
    On Error GoTo Err_cmdOpenRpt_Click
    Dim strWhere As String
    If Not IsNull(Me.cboTypeId) Then
        strWhere = "[TypeId] = " & Me.cboTypeId
    End If
    Dim stDocName As String
    stDocName = "Products"
    MsgBox "strWhere: " & strWhere
    DoCmd.OpenReport stDocName, acPreview, , strWhere
    
Exit_cmdOpenRpt_Click:
    [s][red]End Sub[/red][/s]
    [b][blue]Exit Sub[/blue][/b]

Err_cmdOpenRpt_Click:
   Select Case Err
       Case 2501
            'ignore
       Case Else
            MsgBox Err.Description
   End Select
    Resume Exit_cmdOpenRpt_Click
End Sub

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks a lot!

it finally works. that deserved a star.

Now I have another problem with the display of my pics in the repport but I'll start a new thread for that.
THANKS!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top