Insert same value in multiple records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I have set up a query that filters out current records. TO make it a
little bit more user friendlier I have created a form to work with those
filtered records.
That query/form have check mark field and date field. In order to "finish
record" I need to place check mark and date in those fields. Is it possible
to assign value (checked and date) to those records together, instead of
entering values individually in each records.
 
Is it possible
to assign value (checked and date) to those records together, instead of
entering values individually in each records.

This could be done for the current record at the click of a button. For
example:

Private Sub DoneBtn_Click()

On Error GoTo ErrHandler

Me!chkDone.Value = True
Me!txtSomeDate.Value = Date

Exit Sub

ErrHandler:

MsgBox "Error in DoneBtn_Click( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Sub ' DoneBtn_Click( )

.. . . where DoneBtn is the name of the button, chkDone is the name of the
check box, and txtSomeDate is the name of the text box displaying a date.
Today's date will be assigned to the current record when this button is
clicked.

If you need to do this to all records displayed in the form, then post back
with the names of these two fields. This will require an UPDATE query.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
I would like to do it at one time to say 20 records that are in the filter
range. In Handbase (palm database) there is a column option <set value to>. I
guess I would like to be able to do the same in access.
 
Since you won't tell me the names of your fields, Bud Abbott helped out. ;-)
Try:

Private Sub DoneBtn_Click()

On Error GoTo ErrHandler

Dim sqlStmt As String

If (Len(Me.Filter) = 0) Then
sqlStmt = "UPDATE (" & Me.RecordSource & _
") SET WhosOnFirst = TRUE, WhatsOnSecond = #" & _
Date & "#;"
Else
sqlStmt = "UPDATE (" & Me.RecordSource & _
") SET WhosOnFirst = TRUE, WhatsOnSecond = #" & _
Date & "# WHERE (" & Me.Filter & ");"
End If

CurrentDb().Execute sqlStmt, dbFailOnError

Exit Sub

ErrHandler:

MsgBox "Error in DoneBtn_Click( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Sub ' DoneBtn_Click( )

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Back
Top