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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default value to ComboBox in table

Status
Not open for further replies.

HRick

Technical User
Aug 4, 2004
4
0
0
I am trying to build a database to keep track of workers hours and prepare billing to client, but am having problems getting the tables to enter default values.
Have one table
tblLaborClass with
ClassNo PK
ClassName

Have second table
tblemployee with
EmployeeID PK
LastName
FirstName
cboClassNo - with RowSource from tblLaborClass

Have third table
tblManHours with
AutoNumber PK
Weekending
cboEmployeeID
LastName
FirstName
cboClassNo

Problems in tblManHours
1.When starting a new record in tblManHours, would like weekending to default to last record.
2.After selecting an EmployeeID in cboEmployeeID, would like cboClassNo to default to value stored in tblEmployee, but with option to change to a value stored intblLaborClass

Hope this makes sense.

HRick


 
Rick

Are you sure about these field names in blue? cmb... usually reserved for the name of combo box objects on a form, not the names of a field on a table.

1.When starting a new record in tblManHours, would like weekending to default to last record.

Assuming the last record has the newest / largest date, and assuming you are refferring to a control on the form, not the default for a table...

I would probablu use the OnCurrent event procedure...

Assumptions:
Weekending - Name of field on the table referring to weekending
cboEmployeeID - Name of field on the table referring to the employee id on the tblManHours. (I suspect the name is really EmployeeID)

The form has two controls
Me.Weekending - bound to table tblManHours, field Weekending
Me.cboEmployeeID - bound to table tblManHours, field cboEmployeeID

Code:
Me.WeekEnding.Default = DMax("[Weekending]", "tblManHours", "[cboEmployeeID] = " & Me.cboEmployeeID)

After selecting an EmployeeID in cboEmployeeID, would like cboClassNo to default to value stored in tblEmployee, but with option to change to a value stored intblLaborClass

Same idea, but use AfterUpdate event procedure for cboEmployeeID

Code:
Me.cboClassNo.Default = DLookup("[cboClassNo]", "tblemployee", "[EmployeeID] = " & Me.cboEmployeeID)

Once again, I am not sure if you provided the name of the field names on the table correctly. Hopefully, you can tweak the suggested solutions as required.

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top