Question : problem with VBA code to operate command on sub-form

Hi, I have a clients contact database in construction.

The tables are 'allClients' and a form based on that table.
There is a subform based on another table.
This table is archive numbers.
One client may have many archive numbers.
I have a report which wants to print a single archive report. for a single client. The primary key for the table the sub form is based on is ArchiveNumber. The prinary key for the parent form is ID
The print button is on the sub form.
The code for the print button doesnt work. I think i need to link the parent form and the sub form but I think i have the coding wrong.
I am told I have a missing operator in nthe query syntax

Any suggestions? Code snippet attached
Code Snippet:
1:
DoCmd.OpenReport "rpt_SingleArchiveRecord", acViewPreview, , "[ID]=Forms![Form_allClients]!AND[Archive number]=Forms![ArchiveTable]![ArchiveNumber]"

Answer : problem with VBA code to operate command on sub-form

test this, assuming the ID and ArchivedNumber are both Number data type


DoCmd.OpenReport "rpt_SingleArchiveRecord", acViewPreview, , "[ID]=" & me.parent.[ID] & " AND [Archive number]= " & Me.[ArchiveNumber]
Random Solutions  
 
programming4us programming4us