Full Version: Setting text box default value based on query
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
bulldawg_15
I am creating a database that should be fairly simple. The database is for a local racetrack and I'm stuck on how to entering race results. I have four tables: Driver, Rank, Home, Class. The form to enter in the results contains a main form with a subform. On the main form there are two combo boxes, one to select the Class of the race, and one to select the Heat of the race: i.e Finals, 1, 2, 3. The subform currently has a text box containing the rank of the driver for that race and the driver's name. I want the Rank to automatically start at one and increase by one each time a new driver is added. The rank field is part of the primary key but cannot be an autonumber field because there will be multiple ranks in the rank table. The rank table contains a primary key of: Class_ID, Rank, Heat. Therefore, each class/heat combo needs to start at 1 and increase. I created a query that finds the max rank value of the class/heat combo and I thought I could use that value +1 for the default value of the Rank field but I'm not having any luck. I have attached the database so that you can see what I all have as there isn't any sensitive information. If it would be easier doing it some other way than using the query that is fine to. I'm open to anything that works. I also want the Driver combo box in the Rank form to be limited to only contain drivers whose Class_ID matches that of the selected class in the main form. I have the row source set up sot that it works when I make my first selection when entering the form but not when I change the selected class and I do have an After_Update event set for requerying. It seems this should be so simple but I'm just missing something. Thanks in advance for your help!
dashiellx2000
I think you may need a few more tables before you can do what you want:
blDriver
DriverID
Name
HomeID
ClassID
tblHome
HomeID
HomeDescription
tblClass
ClassID
ClassDescription
tblRaces
RaceID
RaceDescription
tblResults
ResultID
RaceID
1DriverID
2DriverID
3DriverID
etc....
bulldawg_15
I ended up getting it work out with my current set up. I used the form's record number as the rank number and that works smoothly. Thanks for the posting.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.