Trying to get a field to generate contents automatically on a form

N

NDBC

I am trying to use access 2003 to record rider details and keep lap times at
a local enduro race. I am trying to input riders details. There are a few
classes of competitors, a grade (rider number 100-199), b grade (rider number
200-299) etc. I have set up an optiion group for rider class so if a grade is
ticked it comes back with the response 100 and 200 for b grade etc. What I
need in the rider number box is the next available rider number to be
generated automatically. For instance if the a grade option is ticked and the
largest rider number in the 100's already stored in the table is 103 then it
automatically comes up with 104 as the rider number. All classes rider
numbers are stored in the one table at this stage. Does it make it easier if
I have a table for each class. I don't know how to make a form look at
multiple tables.

I have developed a query that can determine the highest number used in any
class based on an input of (100, 200 etc) but don't know how to use a query
from a form if this is an option.

I have a very limited experience with access and vba so may need very
detailed help if possible but any advice will be gladly accepted.

Thanks
 
K

Keith Wilby

NDBC said:
I am trying to use access 2003 to record rider details and keep lap times
at
a local enduro race. I am trying to input riders details. There are a few
classes of competitors, a grade (rider number 100-199), b grade (rider
number
200-299) etc. I have set up an optiion group for rider class so if a grade
is
ticked it comes back with the response 100 and 200 for b grade etc. What I
need in the rider number box is the next available rider number to be
generated automatically. For instance if the a grade option is ticked and
the
largest rider number in the 100's already stored in the table is 103 then
it
automatically comes up with 104 as the rider number. All classes rider
numbers are stored in the one table at this stage. Does it make it easier
if
I have a table for each class. I don't know how to make a form look at
multiple tables.

I have developed a query that can determine the highest number used in any
class based on an input of (100, 200 etc) but don't know how to use a
query
from a form if this is an option.

I have a very limited experience with access and vba so may need very
detailed help if possible but any advice will be gladly accepted.

Thanks

I'm assuming that you're using a form to manipulate your data (as you should
be!).

I'm also assuming that you have a text box called "txtUniqueNo" bound to a
field "UniqueNo" in table "tblEnduro" and your option group is bound to a
number field "Class" and is called "ogrClass" and that the option values are
100 (a), 200 (b) etc. Something like this should work in the form's Before
Update event (untested):

Me.txtUniqueNo = Nz(DMax("UniqueNo", "tblEnduro", "[Class] = " &
Me.ogrClass)+1,Me.ogrClass)

The "Nz" handles the case where there is no number for the selected class,
in which case it will take the value assigned to the selected option.

If your Class field is a text field then you'll need to use quotation marks:

Me.txtUniqueNo = Nz(DMax("UniqueNo", "tblEnduro", "[Class] = ' " &
Me.ogrClass & " ' ")+1,Me.ogrClass)

I've included extra spaces around the single quotes for clarity, you should
not include them in your code. The number will be assigned when the record
has been saved.

Hope that makes sense.

Keith.
www.keithwilby.co.uk
 
S

Stefan Hoffmann

hi,
I have developed a query that can determine the highest number used in any
class based on an input of (100, 200 etc) but don't know how to use a query
from a form if this is an option.
You can use DLookup(), e.g. in the form's Before Update event

Private Sub Form_BeforeUpdate(Cancel As Integer)

Me![RiderNumber] = DLookup("[Number]", "yourQueriesName")

End Sub




mfG
--> stefan <--
 

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