Re: Changing records by query?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Jeff (JeffKlein_at_Associatedoffices.com)
Date: 08/26/04


Date: Wed, 25 Aug 2004 22:32:26 -0500

Below is code that exists in a command button. How do I complete this code
to edit the record it finds and replace the StartDate with the
txb_StartDate.value?

Dim dbs As Database
Dim strSQL As String

        Set dbs = CurrentDb
        strSQL = "SELECT Meetings.MeetingID FROM Meetings WHERE
(((Meetings.MeetingID)=txb_ParentMeetingID.value));"

"Jim Allensworth" <JimNOT@datacentricsolutions.com> wrote in message
news:412ce435.18380062@netnews.comcast.net...
> On Wed, 25 Aug 2004 13:33:50 -0500, "Jeff"
> <JeffKlein@Associatedoffices.com> wrote:
>
> >I have a form that shows the current record (From table). I have a cmd
> >button that uses the values from the current record to make a new record
> >with certain fields that are the same as the original record. This works
> >OK. Now comes the part that I don't know about.
> >Both records have a StartDate and an EndDate. When I click the command
> >button I need the Original record's EndDate to be changed to the
StartDate
> >of the new record. This makes the new record supercede the old record. I
> >have a textbox on the form that show the original records ID
> >
> >I thought if I could make a select query for the ID then change it this
> >might work. I am not sure how to add this query to my cmd button.
> >
> >What is the best way to code the cmd button.
> >Maybe there is a better way??
> >
>
> You don't need a query to do this. It sounds like the command button
> is starting a new record with certain fields retaining previous data.
> To do what you want use the form's On Current event and chech for a
> new record if it is a new record set the new records StartDate control
> to the old records EndDate control. Something like...
>
> Private Sub Form_Current()
> If Me.NewRecord Then
> Me.txtStartDate = Me.txtEndDate.OldValue
> End If
> End Sub
>
> - Jim


Quantcast