Open Form showing Selected Vendor only

D

Dave Elliott

Need form BlankChecks to open with criteria from combo187 on form
frmAutoPayrollReport
Table where Combo187 comes from is VendorInfo
Query where Combo187 comes from is Vendor Field is Vendor
Form where combo187 is on is named frmAutoPayrollReport
How can I make the combo187 open the form BlankChecks showing whatever I
input into the Combo187 Drop Down List?




On Error GoTo Err_Command167_Click
Dte1 = Forms!frmAutoPayrollReport!BeginDate
Dte2 = Forms!frmAutoPayrollReport!EndDate
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "BlankChecks"
DoCmd.OpenForm stDocName where [Customers] =
[Forms]![frmAutoPayrollReport]![Combo187]"
Me![Combo187] = Null
Exit_Command167_Click:
Exit Sub

Err_Command167_Click:
MsgBox Err.Description
Resume Exit_Command167_Click
 
J

Jim Allensworth

Dave, comments in-line...

Need form BlankChecks to open with criteria from combo187 on form
frmAutoPayrollReport
Table where Combo187 comes from is VendorInfo
Query where Combo187 comes from is Vendor Field is Vendor
Form where combo187 is on is named frmAutoPayrollReport
How can I make the combo187 open the form BlankChecks showing whatever I
input into the Combo187 Drop Down List?




On Error GoTo Err_Command167_Click
Dte1 = Forms!frmAutoPayrollReport!BeginDate
Dte2 = Forms!frmAutoPayrollReport!EndDate
Do yourself a favor and use the Me keyword to refer to the form that
is holding the code. Also reports as far as that goes. Me "dot" will
bring up intellisense to help select form objects and controls. And
the code will be easier to read for maintenance.

Dte1 = Me.BeginDate
Dte2 = Me.EndDate
Dim stDocName As String
Dim stLinkCriteria As String
Again for future readability put your Dim's at the top of the
procedure.
stDocName = "BlankChecks"
DoCmd.OpenForm stDocName where [Customers] =
[Forms]![frmAutoPayrollReport]![Combo187]"
You don't need the "Where" for the where condition - it's implied. And
it needs to be a string.

DoCmd.OpenForm "BlankChecks",,,"Customers = " & Me.Combo187
Me![Combo187] = Null
Exit_Command167_Click:
Exit Sub

Err_Command167_Click:
MsgBox Err.Description
Resume Exit_Command167_Click
And seriously consider using a naming convention - like the
Leszynski/Reddick style.

http://www.mvps.org/access/general/gen0012.htm

And remember F1 is your friend. (well, at least in A97)

- Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top