How to browse a form as a table?

M

Marcel Nihon

Hello,
In VBA for Access, how can we browse a form created on a table to, for
example, reset a control to zero from the first to the last line?
Thanks for your help.
 
M

Michel Walsh

Hi,


You reset the fields in the table that is bound to the control in the
form and then refresh the form.

' consider the case where the form is dirty, ie. some modifications have
not yet been saved
If Me.Dirty then
Select Case MsgBox("Save pending changes [OK], " & vbCrLf & _
" or Undo them [Cancel] before continue? ", _
vbOKCancel, "Pending changes not yet saved")
Case vbOk
Me.Dirty=false
Case vbCancel
Me.Undo
Case Else
Debug.Assert False 'code execution should not be here,
' have I changed the MsgBox possible results?
' without having change the Select Case statement?
End Select
End If

' Reset to 0 all the records in the table
CurrentDb.Execute "UPDATE tableName SET fieldName=0", dbFailOnError

' refresh the form to get back those new zeros
Me.Refresh




Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top