By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,398 Members | 1,362 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,398 IT Pros & Developers. It's quick & easy.

Form unbound text box update with query

P: 5
I have a query to add a record to table which is fine. What I am trying to accomplish is to one
1>Find the highest value assigned to the part # in the same table. This was done with another extra query.
a.QryMaxAGL
Expand|Select|Wrap|Line Numbers
  1. SELECT Max([TAGLserial].[AGLID]) AS AGLmax FROM TAGLserial;
2> Create a text box (unbound) in the form that show the value of the AGLmax + 1
3> Assign this value to one of the field in the table when the user add a new record.
In summary, I have used the following, but I can’t get it to work.
Expand|Select|Wrap|Line Numbers
  1.     Me.text101=  SELECT Max([TAGLserial].[AGLID]) AS AGLmax FROM TAGLserial;
Property sheet,
control source = SELECT Max([TAGLserial].[AGLID]) AS AGLmax FROM TAGLserial;
Any comment would be greatly appreciated.
Jul 4 '14 #1
Share this Question
Share on Google+
4 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,482
First, please use code tags when you post code.

Second, your text box should be bound to your table, to make it easier to tie directly into that table.

Third, to set the value of a text box, you cannot use a SELECT statement, but you can use the value from that query. To assign the value of the next ID, try this:

Expand|Select|Wrap|Line Numbers
  1. Me.txt101 = DLookup("[AGLID]", "QryMaxAGL") + 1
Since you are only pulling one record in your query, this should work.

There may be better ways to do what you are doing, but if you want to generate your own IDs, this is one way to do it.
Jul 4 '14 #2

P: 5
I really appreciated your help. I don't want to admit the hours reading and trying. It worked like a charm.
Thanks.
What do you mean?
"First, please use code tags when you post code. "
Thanks
I am new to this, and appreciate all recommendations.
Jul 4 '14 #3

NeoPa
Expert Mod 15k+
P: 31,768
Pbabin:
What do you mean?
"First, please use code tags when you post code."
When posting code (of any variety) it is important to use [code] tags so that the code can be viewed more easily and clearly. This is a rule of the site that new members often need to be reminded of. As an illustration I've updated your first post.

Without the tags it's very hard to see the code that you post in any sort of context. When posting your comments the [code] tags button is always available.
Jul 4 '14 #4

P: 5
Understood and will do.!
Thanks again for your time.
Jul 5 '14 #5

Post your reply

Sign in to post your reply or Sign up for a free account.