help!! button to add values to field

hullstorage

Registered User.
Local time
Today, 22:47
Joined
Jul 18, 2007
Messages
213
i have a query that calls all postcodes beginning with AB
what i then have is a form that shows these results

i want something like a button that when clicked will replace current values in county to "scotland"

maybe something like this:

If me.county is not like "SCOTLAND" Then
me.counuty ="SCOTLAND"
End If
 
Personally, I would just do an update query.
Set the criteria in the Postal Code field to "AB"
and the update to in the County field to Scotland.

If there is a reason to do them one at a time (example: not all AB codes are in Scotland) then add a button to your form. The button should be set for Next Record.

Change the coding in the On Click to:

Private Sub Command30_Click()
On Error GoTo Err_Command30_Click


If me.county is not like "SCOTLAND" Then
me.counuty ="SCOTLAND"
End If

DoCmd.GoToRecord , , acNext



Exit_Command30_Click:
Exit Sub

Err_Command30_Click:
MsgBox Err.Description
Resume Exit_Command30_Click

End Sub


Code in red should already be there.

If you would like to actually see the change in the form, remove the line
DoCmd.GoToRecord, , acNext
This will also remove the go to next record function.
 

Users who are viewing this thread

Back
Top Bottom