Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form default values

Status
Not open for further replies.

bulldawg15

Programmer
May 19, 2005
11
US
I am creating a database that should be fairly simple. The database is for a local racetrack and I'm stuck on how to enter in 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. 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!
 
I created a query that finds the max rank value of the class/heat combo +1 for the default value of the Rank field but I'm not having any luck."

I've had problems using the default value like this too - i was getting duplicate entries of the same number. for me, the solution was to set the value in the Form_BeforeUpdate event, instead of the field's Default value. example:
Private Sub Form_BeforeUpdate()
If isnull(Me.txtRank) Then txtRank = DMax("[drvRank]", "tblDriver") + 1
End Sub

"I also want the Driver combo box to only contain drivers whose Class_ID matches the class in the main form ... I do have an After_Update event set for requerying."

Try using the Change event instead of After_Update. I seem to recall this worked for me in the past

Hope it helps!

-roppetech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top