Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2002
    Posts
    2

    Post Unanswered: newbie: append query

    I'm tryng to use an append query that moves records fom table1 to table2 witha linked button on a forms based on table1. The query works but append always all the records in table1 to table2 and not only the one present in the form where i'm working. How can i limt the append only to the record present in the forms?

    Here is the sql :
    INSERT INTO Preosp ( DATAimmiss, PATOLOGIA, COGNOME, NOME, ETÀ, TELEFONO1, TELEFONO2, TIPOPatologia, [Note particolari] )
    SELECT DISTINCT PazVisitati.DATAimmiss, PazVisitati.PATOLOGIA, PazVisitati.COGNOME, PazVisitati.NOME, PazVisitati.ETÀ, PazVisitati.TELEFONO1, PazVisitati.TELEFONO2, PazVisitati.TIPOPatologia, PazVisitati.Note_Anam
    FROM PazVisitati;


    I'know is a stupid problem but i'm new to access sql code...

    Thanks in advance for your help


    RBELL

  2. #2
    Join Date
    Jun 2002
    Posts
    3
    Not a stupid question... I ran into this a while ago. What I did was create a cache table that captured the current data for the current record that was being entered, then had it clear that record from the cache table using 1 button that ran a command that:

    - updated a temporary table with the current data that was in the DB (tblCustomerInfo) then it
    - moved the data to the final destination table (tblFinalDestination) then,
    - cleared that data from the temporary table (tblTempCustomer). (This table has data only for a moment as it moves from one location to another...)

    Once the data runs ends up at it final destination, it is displayed in a suform (from tblFinalDestination).

  3. #3
    Join Date
    Jun 2002
    Posts
    2
    Thanks for your kind help... I'll try but could you please send me same code about the steps you described....
    Another problem I had with the query is to move records (i mean copy to another table and delete from the origin) is possible to solve with querys? Thanks again

    RBell


    Originally posted by ScottAlex1
    Not a stupid question... I ran into this a while ago. What I did was create a cache table that captured the current data for the current record that was being entered, then had it clear that record from the cache table using 1 button that ran a command that:

    - updated a temporary table with the current data that was in the DB (tblCustomerInfo) then it
    - moved the data to the final destination table (tblFinalDestination) then,
    - cleared that data from the temporary table (tblTempCustomer). (This table has data only for a moment as it moves from one location to another...)

    Once the data runs ends up at it final destination, it is displayed in a suform (from tblFinalDestination).

  4. #4
    Join Date
    Jun 2002
    Posts
    3
    here is a short sample of the code...

    Dim strSQL As String
    Dim db As Database
    Dim intrecordID As Integer
    Dim strcustname As String


    Set db = CurrentDb()

    strUserCAI = Me.custname
    intProblemID = Me.recordID

    'Loads data into TBL_CustomerInfo for Append_CustInfoHist query to run to move data to CustInfoHist table...

    strSQL = "INSERT INTO tblTempCustomer ( recordID,custName ) VALUES (" & intrecordID & ", '" & strcustName & "');"

    db.Execute strSQL

    DoCmd.SetWarnings False

    Dim stDocName As String

    'Runs Append_tblTempCustomer query

    stDocName = "AppendtblTempCustomer"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

    'Runs QRYdeletetblTempCustomer to delete data from CustInfo Table. This prevents duplication of the record

    stDocName = "QRYdeletetblTempCustomer"
    DoCmd.OpenQuery stDocName, acNormal, acEdit


    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •