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

set data in field from form 2

Status
Not open for further replies.

Yardyy

Technical User
Aug 13, 2002
448
GB
Hi, not sure how to do this, so here goes.. I have a form based on a jobns form, there is an employee_id field in there that has relationship to the employee table. On the jobs form what i want is when i press the save button that the fields Employee_Available_Time and date are set to null or 0, how do i do that with code ??

I have used the following code before

Me.company = DLookup("CompanyName", "Contacts", "ContactID=" & Nz(Me.ContactID, 0))

and thought that maybe i could tweak that to fit my purpose..

any help most appreciated.

Many Thanks
Yurov Ardyy
 
It may be possible to include the relevant field through a query that joins Jobs and Employees and update with a little code:

Code:
Me.CouldBeHidden_Employee_Available_Time=0

Alternatively, you could use an update query:

Code:
strSQL="Update Employees Set Employee_Available_Time=0 " _
& "Where EmployeeID=" & Me.EmployeeID
CurrentDB.Execute strSQL, dbFailOnError

 
Hi, thanks for the reply, tried the bottom code, and amended it slightly..

strSQL="Update Employee Set Employee_Available=0 " & "Where Employee_No=" & Me.Employee_No CurrentDB.Execute strSQL, dbFailOnError

but its coming up with a syntax error.. not sure why, all the spelling is right for the fields and tables.

Many Thanks
Yurov Ardyy
 
You must have TWO lines of code:
Code:
strSQL="Update Employee Set Employee_Available=0 Where Employee_No=" & Me.Employee_No
CurrentDB.Execute strSQL, dbFailOnError

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top