bound textbox problem when autofilled

pyt

New member
Local time
Today, 12:17
Joined
Jul 30, 2013
Messages
4
Hi there,

I am fairly new to access (just a few months) and I have a problem and hopefully somebody can give me an answer.

I have a bound textbox on a form that is linked to a date field on the table via the control source property. In that same form beside it I have a command button to autofill the textbox with the current date. So the textbox can either be filled using the command button or typed into if it needs to be other than the current date. However, when it is autofilled using the command button, it does not update the table. Only when the date is typed into the textbox, does it update the table. Is there a way to fix this ?

Thanks,
 
Please post your code that is performing the autofill.

A suggestion, set the default value for this date field to Date() and that will be the current date and may alleviate the need for a button.
 
Hi Bill,

Thanks for responding. The code is very simple.

Private Sub cmdReviewCompleted_Click()
Me.Complete.Value = Date
End Sub

Private Sub cmdLastUpdate_Click()
Me.Update.Value = Date
End Sub

I can't use default value because the dates have to come from the record on the table using the control source property.

I've attached a picture of a portion of my form where i am having problems. the funny thing is, when i select an auditor and use the buttons, they work. But if I don't touch the combo boxes and just click on the buttons, the value of the texbox does not get saved. Btw, the combo boxes are not at all linked to the textboxes in the properties nor in the code itself.

Thanks again . . .

Polly
 
Using the default value does not affect the Control Source and is a good way of guiding the data entry process especially for fields that don't change much.

Try changing the code:
Code:
Me.Complete = Date()

Code:
Me.Update = Date()

Just a consideration, Update is a reserved word and although you can get away with using it, it might cause confusion at some point. Try using general syntax such as putting txt before Text fields, int before number fields and dt before Date fields. This helps identify what they are and also prevents you from accidentally using a reserved word.
 
Thanks for the tip. The code change did not work. The field only gets updated when I manually type in the dates.
 
try to force save the record by using:

Code:
Private Sub cmdReviewCompleted_Click()
Me.Complete.Value = Date
if me.dirty then me.dirty = false
 
End Sub
 
Thanks but I've already tried that and I tried it again right now just to double check and that doesn't work too. =(
 
ok. I may suggest that you change the names of those controls slightly as the other post suggested: dtUpdate and dtComplete. the word "Complete" and "Update" may be freaking out the VBA. I know that "Update" is a reserved word.
 
Last edited:
If you want to post your DB I can take a look, it's odd so I'm guessing it will something simple.
 
Does any code execute? In version 2007 and later, when no VBA code executes, the problem is usually that the folder holding the database hasn’t been designated as a "Trusted" location.

To "Trust" your folder, click:
  • Office Button (top left)
  • Access Options (bottom of dialog)
  • Trust Center (left)
  • Trust Center Settings (button)
  • Trusted Locations (left)
  • Add new location (button)
Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom