Results 1 to 5 of 5

Thread: Updating a Form

  1. #1
    Join Date
    Sep 2001
    Posts
    175

    Question Unanswered: Updating a Form

    I have a continuous form with a field called FIELD1. I have written some code that would select records from a table (one or more records can be selected). How can I update FIELD1 with the records that were selected from the table. Remember it is a continuous form and when you initially enter the form you only see one row.

    When I run the code I am getting more than one record but in the form I am only seeing the last record.

    Is there a way to display all the records?????

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    ...if your "some code" code results in an SQL string called strSQL, try:

    forms!nameOfYourMain!nameOfYourContinuousSub.recor dsource = strSQL

    -or- if it's not a subform

    forms!nameOfYourContinuousForm.recordsource = strSQL

    substitute the real names of the forms of course.

    izy

  3. #3
    Join Date
    Sep 2001
    Posts
    175
    I am getting the following error when I tried your code: The Microsoft Jet database engine cannot find a record in the table with key matching fields".

    I think you can only use "recordsource" to display data from a query, table or SQL statement and unfortunately I am using an array. Check out my code below:

    Set AceDbs = CurrentDb
    strsql = "SELECT [code] FROM tblpolperils WHERE tblpolperils.invoiceno = " & Me!Text20
    Set rst = AceDbs.OpenRecordset(strsql)
    rst.MoveLast
    rst.MoveFirst

    noorecords = rst.RecordCount
    For inti = 0 To (noorecords - 1)
    burgarray(0, inti) = rst!code
    rst.MoveNext
    Next

    For inti = 0 To (noorecords - 1)
    With rst
    Forms!frmpolperils1.RecordSource = burgarray(0, inti)
    End With
    Next
    rst.Close

    It's the values in burgarray I need to display in the form.

    Any other ideas????

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    good old help says:
    You can use the RecordSource property to specify the source of the data for a form or report. You can display data from a table, query, or SQL statement.
    now i can agree that there are times when an array is nice, and i even have a big app that refers to a huge array of mock-constants pulled from a table, but the array is only there for intermediate calculations - it is never displayed.

    an access table is ...an array. simplify your life - instead of your array use a temporary table. use your SQL to maketable. make some more SQL to delete *.


    izy

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    further thought:
    append & delete * (insetad of make...)

    izy

Posting Permissions

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