Query gives syntax error

kirkm

Registered User.
Local time
Today, 13:13
Joined
Oct 30, 2008
Messages
1,257
I want to update all Field4's in my datasheet Form1 to the value d-clicked
in the Field4 Double click event (if a value exists).
Code:
Update Form_Form1.Field4 = Me!Field4 Where Form_Form1.Field4 is null
What am I doing wrong ?
 
incorrect syntax. you need a Table to update:

Update TableName Set Fieldname = Value Where <condition>

you are updating a field by its Value?
 
I was wondering that. So I'd use the Forms record source ?
Yes, updating null fields to the value c-clicked.
 
where does the Update coming from (which field)?

Yes, updating null fields to the value c-clicked.
does, this mean, you "double-click field4 (the one that is not null), then
all field4 (which are blanks) on your form get updated by this Value?
 
Yes arne, 100%. But I've got to be a bit careful as the form is based on a Filtered query.
 
Code:
Private Sub Field4_DblClick(Cancel As Integer)
    Dim varValue As Variant
    varValue = Me!Field4
    With Me.RecordsetClone
        If Not (.BOF And .EOF) Then
            .MoveFirst
        End If
        Do Until .EOF
            If IsNull(!Field4) Then
                .Edit
                !Field4 = varValue
                .Update
            End If
            .MoveNext
        Loop
    End With
End Sub
 
Thanks Arne. So an update Query is the wrong approach?
It is working perfectly but from Private Sub txtField4_DoubleClick.
varValue = Me!txtField4 worked but it could not find !txtFleld4. That had to be just "!Field4"
Most baffling.. to me !
Thanks...
 
arnelgp never had txtField4? :unsure:
 

Users who are viewing this thread

Back
Top Bottom