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

Updating fields from command button

Status
Not open for further replies.

ramrags

IS-IT--Management
Aug 17, 2001
62
US
I'm trying to come up with a time sheet for my database. What I have is a blank form with to sub-forms the blank form is called frmNewTime, the first form I put on this is a form I call frmTime this is just built from a query that gives the Employees name, it's a Continuous form with a command button to pick the employee who's time to add. The other form is called frmEmpTime and is built from a table tblTIME_LINE that stores the EMP_NUM, JOB_NUM, LINE_RATE, HOURS_WORKED, LINE_RATE, and LINE_DATE. What I would like this to do is when you press the command button for the employee on the frmTime form, update the EMP_NUM and the LINE_RATE fields on the frmEmpTime form. The data comes from two tables' tblEMPLOYEE and tblCRAFT, the EMP_NUM is the key on the employee table and CFT_NUM is the foreign key. I've tried different things but nothing seems to work right. Please put me in the right direction Thank you for any help. Tom
 
You need to use the DLookUp function the OnClick event of a command button to get the information you need and pass if along to the appropriate fields.

DLookUp operates in the following way:

Name of field, table where information is stored, criteria for the match

Heres an example:
I have a table called tblContacts with the following information: ContactID (Unique), FirstName, LastName, Phone Number

I have a form with 3 unbound textboxes: txtID (Where I enter the unique ContactID from tblContacts), txtFName, txtLName and a command button cmdInfo

I add the follwoing to the On Click event of cmdInfo:

Dim rsFnm as Variant
Dim rsLnm as Variant

rsFnm = DLookUp("[FirstName]","tblContacts","[ContactID] = " & me.txtID

rsFnm = DLookUp("[LastName]","tblContacts","[ContactID] = " & me.txtID

txtFName = rsFnm
txtLName = rsLnm


This will add the first and Last name to the unbound textboxes txtFName and txtLName

HTH

"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
Thanks for the response but will this work for what I assume I need a querry. what I'm looking for it to do. On form 1 with the command button, when you click the cmdEmp button pass the EMP_NUM (unique), Select the Craft number(foreign key)on the employee table and select the craft rate ($.$$) from the Craft table. I will try the DLOOKUP and hope it works thanks again. Tom
 
I wanted to tell you that I went back and read the help file where i got my answer to my last ? and I got it to work. Thanks again for the help. Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top