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

Opening as form by date

Status
Not open for further replies.

integritycare

Technical User
Mar 12, 2011
151
AU
Hi all,
I have a need to open a form by using a date.

I have used this code to open an invoice, by invoice number, but how do I change it to open a form by date

Code:
DoCmd.OpenForm "Accounts-R", , , "InvoiceNumber=" & Me.InvoiceNumber

Many thanks,

Integrity

 
DoCmd.OpenForm "Accounts-R", , , "InvoiceDate=#" & Me.InvoiceDate & "#"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PHV,

Many thanks for your help.
However it does not seem to work and it probably is because I did not give enough info.
I was just trying to be brief..
What I have is a mainform which has a text box, SDate(Data Type is Date/Time)
On that text box I have put your code

Code:
Private Sub SDate_Click()

DoCmd.OpenForm "frmInvoiced-Hrs", , , "SDate=#" & Me.SDate & "#"

End Sub

SO it opens a form (frmServiceDates) by the text box (SDate)
The form to open "frmInvoiced-Hrs" has the same text box (SDate) with same datatype


The form will open but has data..
Many thanks,

Integrity




 
The RecordSource of frmInvoiced-Hrs should have a field named SDate.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PHV,

Yes that form's record source does have a field, (SDATE)

Code:
SELECT tblAccountsData.SDate, tblAccountsData.D1, tblAccountsData.N1, tblAccountsData.SS1, tblAccountsData.Sun1, tblAccountsData.PH1, tblAccountsData.PPHR1, tblAccountsData.La1, tblAccountsData.TWHrs, tblAccountsData.StaffID, tblAccountsData.SFirstname, tblAccountsData.SLastname, tblAccountsData.La1, tblAccountsData.ODTotal
FROM tblAccountsData;

This is the query code.

Integrity
 
So, what is the problem ?
To be sure, I'd try this:
DoCmd.OpenForm "frmInvoiced-Hrs", , , "SDate=#" & Format(Me.SDate, "yyyy-mm-dd") & "#"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top