Module or Lookup Code Needed; See Code Below

D

Dave Elliott

I am trying to open my form named TimeCards and only show the records
(Invoices) that are due, that is that the sub-form on the main form
TimeCards status is not Invoiced.
The sub-form is named FTimeBillingSub. Where the control BillPer isnull,
then it needs to be billed.
This code will be run from another form named frmAutoPayrollReport command
button, or called via a module???
Unsure of how to input Where condition into either query or module.
Code to check for TimeCards not Invoiced is :
If IsNull("Forms!FTimeBillingSub!BillPer") Then
MsgBox "Job Has Not Been Invoiced Yet"
End If

The code below normally runs when the TimeCards form opens , just with
different criteria.
Need new module or else query ???
The code Line MyWhere=MyWhere & (" And , etc..... is the line that needs
editing




Dim db As DAO.Database
Dim qd As QueryDef
Dim Mywhere As Variant, Var1 As Variant
Var1 = [Forms]![frmAutoPayrollReport]
Set db = DBEngine.Workspaces(0).Databases(0)
On Error Resume Next
db.QueryDefs.Delete ("QDynamicQuery")
On Error GoTo 0

Mywhere = Null
Mywhere = Mywhere & (" And [BillPer] Like '" +
[Forms]![frmAutoPayrollReport]![Forms!FTimeBillingSub!BillPer]+ "'")
Set qd = db.CreateQueryDef("QDynamicQuery", "Select * From QDates " &
("Where " + Mid(Mywhere, 6) + "ORDER BY [TimeCounter] ASC ;"))
DoCmd.OpenForm "TimeCards"
 

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