help with code test

whojstall11

Registered User.
Local time
Today, 09:08
Joined
Sep 7, 2011
Messages
94
PHP:
Private Sub cmdUpdate_Click()
	DoCmd.RunSQL "UPDATE [Hardware Asset]" & _
	" SET [Hardware Asset].[OS] = """ & Me.[OS] & _
	""" WHERE [Hardware Asset].[AssetNumber] = """ & Forms![Hardware Asset Update Form]![AssetNumber] & """"

End Sub
 
Sudoku is more fun than guessing what you want :D

What I mean is that we are good, but we are not mind readers.
 
Spike is correct. Post an actual question along with your code. What do you need help with?

Now, that being said, I see a couple of things how I would write it differently.

My version:
Code:
Private Sub cmdUpdate_Click() 
    Dim db As DAO.Database
    Dim strSQL As String

   Set Db = CurrentDb

   strSQL = "UPDATE [Hardware Asset]" & _ 
    " SET [Hardware Asset].[OS] = " & Chr(34) & Me.[OS] & Chr(34) & _ 
    " WHERE [Hardware Asset].[AssetNumber] = " & Chr(34) & Forms["Hardware Asset Update Form").AssetNumber & Chr(34) 
    db.Execute strSQL, dbFailOnError
End Sub

And if your AssetNumber is a Number and not text, then:

Code:
Private Sub cmdUpdate_Click() 
    Dim db As DAO.Database
    Dim strSQL As String

   Set Db = CurrentDb

   strSQL = "UPDATE [Hardware Asset]" & _ 
    " SET [Hardware Asset].[OS] = " & Chr(34) & Me.[OS] & Chr(34) & _ 
    " WHERE [Hardware Asset].[AssetNumber] = " & Forms("Hardware Asset Update Form").AssetNumber  
    db.Execute strSQL, dbFailOnError
End Sub
 
IM so sorry about that I was trying see where my co workers code was lined up at. We were trying to figure out how to set more records to update. All the quotations were confusing me.
 

Users who are viewing this thread

Back
Top Bottom