Using Database result in form

M

Mike McBurney

I have a quick question from a Newbie. I would like to
use a value returned from a database query as a variable
in a form. Here's the scenario:
I query the database to find the highest value for my
record [Select RequestNumber from Results Where Key=
(Select Max(key) From Results)]. That gives me a result
called RequestNumber which I would then like to increment
and use as a variable when I add a new record. Namely
RequestNumber + 1 would be the next record to add.

So far I have not been able to access RequestNumber on the
form. Any ideas?

Thanks
 
G

grw

How have you tried to read "RequestNumber" ?
Also, in incrementing it - how do you guarantee another user hasnt updated a
record whilst you are entering yours?

In short, why do you want key + 1 ?
 
M

Mike

So far I've tried <%=Request("RequestNumber")%> and <%
=FP_FieldVal(fp_rs,"RequestNumber")%> to no avail.

You are correct in that I do want key + 1. However the
database result shows up as Expr1000 which I could not
access. Since the database results would let me use the
column names from the database (i.e. RequestNumber), I
tried that instead. I'm thinking I will have to write a
VB script when the form opens to run the same query and
assign the value to a variable.

Sound reasonable?
Thanks
-----Original Message-----
How have you tried to read "RequestNumber" ?
Also, in incrementing it - how do you guarantee another user hasnt updated a
record whilst you are entering yours?

In short, why do you want key + 1 ?


Mike McBurney said:
I have a quick question from a Newbie. I would like to
use a value returned from a database query as a variable
in a form. Here's the scenario:
I query the database to find the highest value for my
record [Select RequestNumber from Results Where Key=
(Select Max(key) From Results)]. That gives me a result
called RequestNumber which I would then like to increment
and use as a variable when I add a new record. Namely
RequestNumber + 1 would be the next record to add.

So far I have not been able to access RequestNumber on the
form. Any ideas?

Thanks


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top