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

Text Box / Control Source problem

Status
Not open for further replies.

MrMcFestoe

Technical User
Apr 6, 2003
119
GB
Somebody might be able to shed some light on this, i have the following code in the control source of a text box, it works fine, it find the last date in a subform for what ever customer is shown, but when the text box is displaying the date it does not update my table. Is this because its a text box? if i place the code in a field it still does not update the field in my table. Stuck on this one

=DMax("[Date of Visit]","[Service History]","ID = " & [Forms]![Customers]![ID] & " and [Reason For Visit] = 'Service'")

Any ideas would help, this is sending my daft [hourglass]
Thanks
 
MrMcFestoe:

When you are using unbound controls (i.e. fields that only display database data, and do not write to any table in the database), what you have is fine. Your textbox will display the last visit date.

However, from your question, it seems you are wishing to use a bound control (i.e. tie the value in the text box to a field in a table). In this case, the control source of your text box must be set to the name of the field. You can use the Default Value property of the text box to place your DMax function call in, or programatically set the value thru VBA.

So, in conclusion:

HTH

Greg


Boss quote from an office meeting: We're going to continue to have these meetings until we figure out why no work is getting done ...
 
Greg

Thanks for the replie, will try that, can the code iam using be put striaght in to VBA code or will if have to be modified?

Thanks
 
I'm guessing that it would need a couple of small modifications to allow for the VBA syntax (and maybe some error checking / logical protocols).

Other than that, it shouldn't take too long for you to get yourself up and running.

Greg

Boss quote from an office meeting: We're going to continue to have these meetings until we figure out why no work is getting done ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top