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

Update Query? 1

Status
Not open for further replies.

tylerwork

Technical User
Aug 20, 2002
31
0
0
US
This is rather complicated to explain, but it's probably pretty simple, actually.

I want an administrative form where you can enter the PRODUCT_ID field as the "filter" and then there are 2 fields below it where you can add in info. What I want a button in the form to do is trigger a query to update all records with the same PRODUCT_ID with the information I put in the 2 fields below.

Example

UNIQUE_ID: 40882
Rec_Date: 10/24/02
Rec_By: TRI

There are 42 records with PRODUCT_ID as 40882. I want the Rec_Date and Rec_By fields in all of those records to be updated (filled in) with the data above. So each of the 42 records will have Rec_Date of 10/24/02 and so on.

How can I do this? And is the easiest way to enter VB in the form or to trigger an Update Query of some sort. Either way, I need specific help setting it up, as I'm new to this type of thing!

Thanks for all the help!!!
 
strsql="Update table1 set Rec_Date = #" & Me![txtDate] & "#,Rec_By = '" & Me![txtReceivedBy] & "' Where PRODUCT_ID = " & Me![txtProductId]

'Change txt... with your control names Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need!
 
Well I changed the field names - and i get no errors, but nothing happens to the data in the table called "Inventory"

any ideas?? :)

Private Sub ALL_BUTTON_Click()

strSQL = "Update Inventory set RECVDTE = #" & Me![DATE_REC] & "#,RECVBY = '" & Me![REC_BY] & "' Where PURCHNO = " & Me![PO_NO]

End Sub
 
Private Sub ALL_BUTTON_Click()
dim db as Database,strSql as string
set db = DBEngine.Workspaces(0).OpenDatabase("Your Database Path")
strSQL = "Update Inventory set RECVDTE = #" & Me![DATE_REC] & "#,RECVBY = '" & Me![REC_BY] & "' Where PURCHNO = " & Me![PO_NO]
db.Execute strSQL
End Sub Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need!
 
set db = DBEngine.Workspaces(0).OpenDatabase("Your Database Path")

what is my database path? should i start at the server level ?
 
If your Table and form in the same database then
Set db = CurrentDb()
If Your table in another database then you need to specify the path like
Set db = DBEngine.Workspaces(0).OpenDatabase("C:\Folder1\Your-Database-name.mdb")
Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top