damixa
asked on
VBA Insert result from sql statement into a form of a field
Hi,
I was hoping to get some help with the following code. I have a field that I need to populate with the result of a sql select statement. Cant seem to work
So when I click a button I need the field to be populated with the max of a value
somehow it cant seem to work. I was reading a bit and noticed that docmd.runsql is not used for select statements. Not sure what to use.
thanks,
I was hoping to get some help with the following code. I have a field that I need to populate with the result of a sql select statement. Cant seem to work
So when I click a button I need the field to be populated with the max of a value
Me.provid = DoCmd.RunSQL "select max(id) from ser_faxes_file"
somehow it cant seem to work. I was reading a bit and noticed that docmd.runsql is not used for select statements. Not sure what to use.
thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried the Me.provid = DMax("[id]","ser_faxes_fil e") +1 but got a type mismatch
ASKER
Actually, I got it to work. Thanks a ton.
<<I tried the Me.provid = DMax("[id]","ser_faxes_fil e") +1>>
If your doing this to generate a sequential number, be aware that DMax() can fail in a multi-user situation (it's possible for two users to end up with the same value.
Instead, you'd use a key generation procedure which locks a table allowing only one value to be generated at a time.
Jim.
If your doing this to generate a sequential number, be aware that DMax() can fail in a multi-user situation (it's possible for two users to end up with the same value.
Instead, you'd use a key generation procedure which locks a table allowing only one value to be generated at a time.
Jim.
ASKER
That Me.provid = DMax("[id]","ser_faxes_fil
I'm a newbie, but if I wanted to add 1 to the max, what would the syntax be?
thanks,
Vinnie