Forms To Reports using specific data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a basic form for entering and editing Workorders, but I have specific reports based on specific data in the form, i.e, I have a Store Name field - There is one report for each store group - How do I create a button that will look at the Store Name on the Form and select the matching report for that Store. I have tried different VB codes and I must be doing something wrong, it either prints empty reports, all of the data is on one report or all the data is on all of the reports. HELP!! I really need to get this solved

Thanks in advance to anyone who may be able to help!
 
Sheryl,

You can insert the following code in the Click event of the command button
that you are using to open the report:

Dim strCriteria As String

' This works when your matching field is text type
strCriteria = "[StoreName] = " & Chr(34) & Me!StoreName & Chr(34)
DoCmd.OpenReport "MyReport", acViewNormal, , strCriteria

' This works when your matching field is a number
strCriteria = "[StoreID] = " & Me!StoreID
DoCmd.OpenReport "MyReport", acViewNormal, , strCriteria

hth,
--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


Sheryl said:
I have a basic form for entering and editing Workorders, but I have
specific reports based on specific data in the form, i.e, I have a Store
Name field - There is one report for each store group - How do I create a
button that will look at the Store Name on the Form and select the matching
report for that Store. I have tried different VB codes and I must be doing
something wrong, it either prints empty reports, all of the data is on one
report or all the data is on all of the reports. HELP!! I really need to
get this solved.
 
Back
Top