unbound field

toleafs

Active Member
Joined
Jun 27, 2005
Messages
498
Hello
ANy help is appreciated...
I have a form that reads a query. I have created an unbound text box (strLChg) to capture when the last time a change was made to the record. What I would like to do is have strLChng write to tblEmployee.
Any ideas?
thanks in advance for your help
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
What I would like to do is have strLChng write to tblEmployee.
Then why not make the text box bound to a field in your table instead of making it unbound?
 
Upvote 0
I tried but does not save the date.
I have the Now() function in the text box? does the make a difference?
thanks
 
Upvote 0
No, that won't work. If you use a bound field, the Control Source is the field name (from your query/table), not a function/calculation.

What you want to do is update the value using VBA when "something" on your form happens (i.e. an After_Update script). So under what conditions do you want this field to be updated?
 
Upvote 0
This is what I have so far: * not working *

Private Sub cmdClose_Click()
Dim db As Database, rsCust As Recordset
Set db = CurrentDb
Dim strSQL As String

strSQL = "UPDATE T_rptTracking "
strSQL = strSQL & "strID= " & Me![strID]
strSQL = strSQL & "', strLastChange= '" & Me![strLastChange]

DoCmd.Close acForm, "frmPerfInd"

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click

End Sub
 
Upvote 0
Forget the VBA code for a moment, and focus on the last question I asked:
So under what conditions do you want this field to be updated?

So what is the purpose of your form?
Are you using it to make data changes?
Under what conditions should the strLastChange field be updated?
 
Upvote 0
Any time a record is changed, I would like the strLChng field to update the table with the Now() function.
The purpose of the form is to track changes.
 
Upvote 0
You would just add this code to the BeforeUpdate event procedure on the Form:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
 
    Me!strLChg = Now()
    
End Sub
 
Upvote 0
Your welcome.

Its easy...when you know how!;)
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,136
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top