UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Adding Date Now() In A Sub Form, Access 2010    
 
   
Mick13
post Oct 11 2018, 09:31 AM
Post#1



Posts: 106
Joined: 21-November 06



After not using Access for over a year I am now struggling to remember how to do things. I have just built a database for my Daughters business but for the life of me cannot remember or work out how to do the following.

I am trying to update a Date Field to show todays date in a sub form after I send an invoice by email.

The main form is called FrmBookings and I have a command button that sends a PDF version of a report via Email. I have converted the macro to VB and I am trying to add code that will also show todays date in the sub form field [Invoice Sent] using the Command Buttons “On Exit” property.

I have tried:

DoCmd.GoToControl "InvoiceSent "
Forms! FrmBookings]![SubFrmInvoice].Form![ InvoiceSent] Date =Now()"

Also

Forms![FrmBookings]![SubFrmInvoice].SetFocus
Forms![ FrmBookings]![ SubFrmInvoice].Form![ InvoiceSent] SetFocus
Forms! FrmBookings]![SubFrmInvoice].Form![ InvoiceSent] =Now()"


Any advice appreciated.

Mick

--------------------
Mick
Go to the top of the page
 
GroverParkGeorge
post Oct 11 2018, 09:41 AM
Post#2


UA Admin
Posts: 34,141
Joined: 20-June 02
From: Newcastle, WA


Two things to check:

Forms! FrmBookings]![SubFrmInvoice].Form![ InvoiceSent] =Now()"

There is a space between the left bracket and InvoiceSent. Is that how the control is actually named?

That final double quote is not necessary. Is that from the actual VBA or an artifact of cut-and-paste?

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Visit My Blog on Facebook
Go to the top of the page
 
Mick13
post Oct 11 2018, 09:57 AM
Post#3



Posts: 106
Joined: 21-November 06



You are correct, I had copied the various version I had tried into Word and copied and pasted.

I had been trying various things and had put double quotes at beginning and end and obviously this was left over.

In conclusion it was worded as follows:


Also the field is InvoiceSent and it was entered correctly when I tired it.

Forms! FrmBookings]![SubFrmInvoice].Form![InvoiceSent] =Now()

--------------------
Mick
Go to the top of the page
 
Mick13
post Oct 11 2018, 10:01 AM
Post#4



Posts: 106
Joined: 21-November 06



I have also tried this
Forms![FrmBookings]![SubFrmInvoice].SetFocus
Forms![FrmBookings]![SubFrmInvoice].Form![InvoiceSent].SetFocus
Forms![FrmBookings]![SubFrmInvoice].Form![InvoiceSent] = Now()

--------------------
Mick
Go to the top of the page
 
GroverParkGeorge
post Oct 11 2018, 10:02 AM
Post#5


UA Admin
Posts: 34,141
Joined: 20-June 02
From: Newcastle, WA


Sorry, I also missed this:

Forms! FrmBookings]![SubFrmInvoice].Form![InvoiceSent] =Now()

Missing open bracket

After you correct that, does this version correctly insert the date and time into that control?

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Visit My Blog on Facebook
Go to the top of the page
 
GroverParkGeorge
post Oct 11 2018, 10:03 AM
Post#6


UA Admin
Posts: 34,141
Joined: 20-June 02
From: Newcastle, WA


Is there a control on the subform with that name?

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Visit My Blog on Facebook
Go to the top of the page
 
Mick13
post Oct 11 2018, 10:37 AM
Post#7



Posts: 106
Joined: 21-November 06



Yes

Sub Form called SubFrmInvoice
with fields
InvoiceID
BookingID
InvoiceSent
InvoicePaid

--------------------
Mick
Go to the top of the page
 
GroverParkGeorge
post Oct 11 2018, 12:42 PM
Post#8


UA Admin
Posts: 34,141
Joined: 20-June 02
From: Newcastle, WA


Is the name of the subform CONTROL which contains that subform also SubFrmInvoice?

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Visit My Blog on Facebook
Go to the top of the page
 
Mick13
post Oct 12 2018, 01:52 PM
Post#9



Posts: 106
Joined: 21-November 06



Sorry for delay in answering, I am assuming by Control you mean the name in the property sheet when I click on the sub form.

The answer is yes the, name I gave the sub form is SubFrmInvoice and it shows as this when I click on the sub form.

The sub form runs from the Table TblInvoice.

--------------------
Mick
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    18th December 2018 - 06:16 PM