How to pu the result of a SELECT MAX(value) FROM table_name into a TextBox

robert_anisoiu

Registered User.
Local time
Today, 13:21
Joined
Oct 27, 2010
Messages
10
Hello,

I have two comboboxes. After the selection is made in each combobox, I input an ordering number in a textbox. The number must start with 1 for each new value of the pair combobox1.value+combobox2.value.

When the user want to add a new record, I want to put in a textbox the last number thas has been input for the pair combobox1.value+combobox2.value.
The SELECT SQL will be "SELECT MAX(ordering_number) from table_name WHERE condition".

My problem is that I don't know how to take the value returned by the SELECT SQL command and to put it into the textbox value.

Any help will be welcome,
Thanks
 
How about using DLookup instead? then you can set your text box based off of that

txtYourControlName = DLookup("FieldName" , "TableName" , "Criteria = n")
 
1) What is the base for Combo1 and Combo2 ??
2) What is the Primary key in your table ?
3) Do you want a LAST or a MAX, (it is not the same).
4) Write a short example of your table, (some records).
 
Oh, and if you need to add one to that number for your new record you can do something like this:

Me.YourControlName = DMax("[YourFieldName]", "tblYourTableName") + 1
 

Users who are viewing this thread

Back
Top Bottom