Re: Duplicate record and change it?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Ron Weiner (weinNoSpam1_at_mindspring.com)
Date: 08/26/04


Date: Thu, 26 Aug 2004 07:01:46 -0400

Jeff

There are probably as many ways to update a record in a table as there are
stars in the sky. Since you do not give us much information about your
table structure, all I can do is to Guess. Below is an UNTESTED guess:

    Dim strSql as string

     strSql = "UPDATE Meetings " _
        & "SET StartDate = #" & txb_StartDate.value & "# " _
        & "WHERE MeetingID = txb_ParentMeetingID.value"
     DoCmd.SetWarnings False
     DoCmd.RunSql strSql
     DoCmd.SetWarnings True

Ron W

"Jeff" <JeffKlein@Associatedoffices.com> wrote in message
news:Oktlo2xiEHA.396@TK2MSFTNGP12.phx.gbl...
> 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));"
>
>
> "Ron Weiner" <weinNoSpam1@mindspring.com> wrote in message
> news:#3AFWVqhEHA.384@TK2MSFTNGP10.phx.gbl...
> > I'd use a Sql Append Query
> >
> > Code might look like:
> > (UNTESTED)
> > Sub MakeNew(StartDate as Date, EndDate as Date, PKCopyFrom as Long)
> > Dim strSql as string
> > strSql = "INSERT INTO YourTable ( SomeField, AnotherField,
StartDate,
> > EndDate ) " _
> > & "SELECT SomeField, AnotherField, " & StartDate & ", " &
EndDate
> "
> > " _
> > & "FROM YourTable WHERE PKField = " & PKCopyFrom
> > DoCmd.SetWarnings False
> > DoCmd.RunSql strSql
> > DoCmd.SetWarnings True
> > End Sub
> >
> > Ron W
> > "Jeff" <JeffKlein@Associatedoffices.com> wrote in message
> > news:%23StqagnhEHA.244@TK2MSFTNGP10.phx.gbl...
> > > I want to have a command button that takes the current record (from a
> > table)
> > > and duplicates it but changes selected fields in the new record.
> > > eg:
> > > I have a record that has a StartDate and an EndDate. I want to
enter,on
> > my
> > > form, a NewEndDate that will reset the EndDate to the NewEndDate and
> then
> > > create a new duplicated record that uses the NewEndDate+1 as the
> StartDate
> > > of the new record. What is the best way to approach this process?
> > >
> > >
> >
> >
>
>


Quantcast