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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Problems

Status
Not open for further replies.

reidgivens

Technical User
Mar 24, 2003
24
US
I have a report that should take the primary keys defined in a form and generate the report with that information. It works with the first two test records in the database, but anything after that doesn't work.

I have the report opened by a button on the form with the proper information, but when the report opens it is empty.

The open report code is:

----------------------------code start

Private Sub open_invoice_Click()
On Error GoTo Err_open_invoice_Click

Dim stDocName As String
Dim numvar As String

numvar = "c_id_num=" & Forms!customers!c_id_num & "AND i_id_num=" & Forms!customers!vehicles!invoice!i_id_num_box & "AND v_id_num=" & Forms!customers!vehicles!v_id_num
stDocName = "customers"
DoCmd.OpenReport stDocName, acPreview, , numvar

Exit_open_invoice_Click:
Exit Sub

Err_open_invoice_Click:
MsgBox Err.Description
Resume Exit_open_invoice_Click

End Sub

--------------------------- code stop

Please help thanks
Reid Givens



Reid Givens
Webdeveloper
 
i think you are referencing a subform improperly?

for one subform:
...i_id_num = Forms![MainForm]![subForm].Form![textbox]

for a subform within a subform:
=Forms![MainForm]![subForm1].Form![subForm2].Form![textbox]

if that's not it....do you have all of the text boxes filled in and you're sure there are records that should match? give data examples.

 
I appreciate the responce, but I'm not sure I'm doing this right.

My database has tables that track customers, vehicles, and invoices for each. Each table has a primary ID of auto numbers, so each of the above fields are integers of that particular record. I have checked the text boxes, and they all have the correct number in them, and the tables do, as well. But it won't send to the report.

The form I am useing is called customers, which has a sub form called vehicles which has a sub form called invoice. I changed it now read like this:

Forms!customers!vehicles.vehicles!invoice.invoice!i_id_num_box

is that the correct way to referrence this?

Thanks




Reid Givens
Webdeveloper
 
for a subform within a subform:
=Forms![MainForm]![subForm1].Form![subForm2].Form![textbox]

which for you would be:
=Forms![Customers]![vehicles].Form![invoice].Form![i_id_num_box]

i got this because i opened a form+subform+subform in design mode. then made a new macro. i chose command SetValue, then below when you say which field you want to set, it will write the code for you as you drill down to one subform and then the next. sometimes i get what code i need by using macros, then converting to vba.
 
Reid,

Is that you? This is tommie. What are you up to? Writing Access code? Are you ready to commit hari-kari yet?

Tommie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top