View Full Version : creating a report from current form and subform???


darksniper
05-30-2008, 04:41 PM
edit: I found out that I cannot have a form and a report accessing the table at the same time, what can I do about it if I want to preview current selected record?

I have been having trouble to create a form with a subform, which after you click a button and it would load up the data of that form and subform into the report. Is there a hint or guide, I have the form and I have the report it is just linking them together gives me a headake.

I found that under report filter I need to add "([id] = Forms![formUsers]![id])"
source is the queury that contains records of form and subform.
and under form I have added a button that previews the report. but I get "database engine could not lock table.." when I press on the button.

on_click event code


Private Sub Command15_Click()
On Error GoTo Err_Command15_Click

Dim stDocName As String

stDocName = "rptlUserInfo"
DoCmd.OpenReport stDocName, acPreview

Exit_Command15_Click:
Exit Sub

Err_Command15_Click:
MsgBox Err.Description
Resume Exit_Command15_Click

End Sub

KenHigg
05-30-2008, 04:46 PM
Just a guess but I'm thinking you need to set up the report with a sub report that mimicks the form/subfrom set you have - ???

darksniper
05-30-2008, 04:48 PM
that should not matter if I am doing a queurry and only passing the id of the form

KenHigg
05-30-2008, 04:56 PM
Instead of putting the id in the filter can you try puttng the id in the query as a parameter?

darksniper
05-30-2008, 04:58 PM
Instead of putting the id in the filter can you try puttng the id in the query as a parameter?

how do I do that?

KenHigg
05-30-2008, 05:07 PM
In the id column just put the following in the criteria line:

Forms![formUsers]![id]

???

darksniper
05-30-2008, 05:17 PM
thx, it worked, You're The Best!!!!

KenHigg
05-30-2008, 05:21 PM
Cool - Glad it worked - :)