where do i wrong?

d_profesor

Registered User.
Local time
Today, 22:32
Joined
Jan 17, 2008
Messages
43
i tried the following code to update a field in a table, table name is Perpindahan Aset.

Private Sub cmdUpdate_Click()
Dim rs As ADODB.Recordset
If Not IsNull(Me!txtIDAset) Then
Set rs = New ADODB.Recordset
rs.Open "SELECT*FROM [Perpindahan Aset] WHERE [ID Aset]=" & Me!txtIDAset, _
CurrentProject.Connection, adOpenDynamic, adLockOptimistic, adCmdText
If rs.EOF Then
rs![Lokasi Sekarang] = False
rs.Update
End If
rs.Close
Set rs = Nothing
End If
End Sub

Then i found error :no value given for one or more parameter, can you help me please...
 
What is the data type of ID Aset in the table? I hope you really have spaces in here: "SELECT*FROM..."
 
data type for [Id Aset] is string (text).

yes, i have a prediction it is about data type because when i changed me!txtidaset with ""text in ID aset""" then it work.

so how to write the code? sory i'm newbie in vba code..what's the syntax?

thanks
 
Try

...WHERE [ID Aset]='" & Me!txtIDAset & "'"
 
thanks it work :), but maybe some others problem, the code won't update anything in field [Lokasi Sekarang]. I tried to remove ...if rs.EOF ..then i found there a change but just for first record in rs. i want to update all the data in rs. i think i have to use other code, something like rs.movenext...right?
 
sory it's solved a half :D. i try ..if not rs.eof..but last record won't change, how to update all record btw?
 
it is solved now. Thanks, i've searched the answer for a day :D, just to get that ..[ID Aset]='" & Me!txtIDAset & "'"...:o.. can you explain how is it work? what's the concept btw, so later i don't need to ask anymore. are there any variation for other data type??

thanks
 
It's because Me!txtIDAset is a TEXT-field and not a numberfield that you have to enclose it in quotes. ;)

JR
 
Glad you sorted it out, and all while I slept! In addition, date/time fields are enclosed by "#".
 

Users who are viewing this thread

Back
Top Bottom