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

Xfer of record information based on 2 querys

Status
Not open for further replies.

danofre

Technical User
Jul 13, 2001
46
US
Have a laptop inventory. On a single form I display avaiable laptops with one query and another list of employees with another list box/query. I would like to know how to highlight an employee and then double click an available laptop and have it copy the employee to the "loaned" table, and uncheck the "available" tab in the main table.
 
I would use a command button, cause double clicking is though sometimes to trap.

Dim db, db2 As database
Dim rst, rst2 As Recordset
Dim SQL As String
Set db = CurrentDb
' Open Loaned table and add a new record
Set rst = db.openrecordset("loaned")
rst.AddNew
rst!EmployeeID = Me!EmployeeID ' this has to match your tables and so on.
rst!Name = Me!Name
rst!DateLoaned = Format(Now, "mm/dd/yy")
rst!TimeLoaned = Format(Now, "hh:nn:ss")
' add more if you need to

st.Update
rst.Close

'Open Laptop table and find laptop ID and change "available" to false
SQL = "Select * from LaptopTable where LaptopID = " & Me!LaptopID_on_form
Set rst2 = db.openrecordset(SQL)
rst2.MoveFirst
rst2.edit
rst2!avaialble = 0 ' use 0 if you want a false or unchecked
' use 1 if you want a True or checked value
rst2.Update

rst.Close
db.Close
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top