SQL Update in Subform (1 Viewer)

Sean75db

Registered User.
Local time
Today, 00:31
Joined
May 16, 2014
Messages
33
Hello, I have a form and a subform based off a query, I am trying to run a SQL update statment from one of the fields in my subform. I know what fields in my table i want to update but the Where part of the statment is what i am having a issue with.

DoCmd.RunSQL "UPDATE [Daily Work] SET [Daily Work].QC_Start_Date = Date(), [Daily Work].QC_Start_Time = Time() WHERE ((([Daily Work].CUS)=[Forms]![QC_Queue_Qry Subform]![CUS]) AND (([Daily Work].LN)=[Forms]![QC_Queue_Qry Subform]![LN]) AND (([Daily Work].Note_Date)=[Forms]![QC_Queue_Qry subform]![Note_Date])))"

What this is trying to do is once the the field is updated i want to set the date and time of that record in my table, basicly i am trying to time stamp the record when the field in my subform in updated.

I am still learning VBA and SQL coding so any ideas would be great.

Thanks
 

bob fitz

AWF VIP
Local time
Today, 07:31
Joined
May 23, 2011
Messages
4,729
What this is trying to do is once the the field is updated ....
I assume that by "field" you mean a control (probably a text box) on a form.
basicly i am trying to time stamp the record when the field in my subform in updated.
If you have a field to store this data in, the table/query that the form is bound to, you just need one line of code in the forms Before Update event to record the current date/time.
 

Sean75db

Registered User.
Local time
Today, 00:31
Joined
May 16, 2014
Messages
33
I think that is part of the problem, the fields i am trying to update are not part of my form or subform. I am trying to update my table. i know if they were on my form or subform i could use:

Me.Fieldname = Now()

In this case that wil not work. What i want to do is once the record that is in my subform is assigned to a worker it time stamps the table of when they started. i know i can make this simple but adding the fields/Controls to the subform but i am trying to limit the amount of data the users see.
 

bob fitz

AWF VIP
Local time
Today, 07:31
Joined
May 23, 2011
Messages
4,729
i know i can make this simple but adding the fields/Controls to the subform but i am trying to limit the amount of data the users see.
Just because a bound control is on a form doesn't mean that it has to be seen. Just change its Visible property to No.
 

Sean75db

Registered User.
Local time
Today, 00:31
Joined
May 16, 2014
Messages
33
Thanks Bob i got it to do what i needed, it didn't work adding them to my subform and changing visiable to no but adding it to the query the subform is based on was all it needed.
 

Users who are viewing this thread

Top Bottom