Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2003
    Posts
    3

    Unanswered: loop through multiple records in subform

    I am trying to loop through multiple records in a subform using VBA. The field that I am trying to access is the childlinkfield, but is not in any control on the subform itself. I am able to access the current record displayed using the following syntax:

    me.subformname.fieldname

    but it does not allow me te enter a positional reference, so I cannot access the subsequent records.

    Please help, this is really irritating me!

  2. #2
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465

    Talking loop through multiple records in subform

    DonnaA

    Proba lo siguiente:

    Dim Variable as Variant
    Variable = [Forms]![Subforms]![item]

    Si asi no anda manda una pequeña demo de tu programa
    para ver mejor cual es el problema

    Saludos Norberto
    Saludos
    Norberto

  3. #3
    Join Date
    Sep 2003
    Posts
    3
    Thanks Norberto, my Spanish(?) is not that good (okay, non existent) but I think I tried what you said. Setting my variable up as a variant still did not allow me to assign a positional reference ie.

    me.subform!item(0)

    and I got the same answer I was getting before. Perhaps someone could translate Norberto's answer for me, I clearly missed something. Thanks!

  4. #4
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    donnaA,
    My spanish isn't any better, so I can't help you there.

    What is it that you are trying to do:

    Move the focus to a certain record on the subform?
    or
    Retrieve a value from a record on the subform, without necessarily
    giving it the focus?
    or
    something else???

    Mark
    Inspiration Through Fermentation

  5. #5
    Join Date
    Sep 2003
    Posts
    3
    Hello Mark, basically I am writing a copy function for a set of records. For each record in my subform, I need to run some SQL code. The focus is irrelevant, as the old form closes and the new form opens with the copied records.

    In a nutshell, I need to loop through each record in the subform and perform an action.

    The function does this so far:

    1. copies the quote, assigns new quote number
    2. copies the quote items, adds new quote number from previous, assigns new quote item IDs
    3. copies quote item other, assigns new quote item other IDs

    Now I need to assign the new quote item IDs from #2 to their associated quote item others in #3. I cannot use the same method (I used DMax function to look up last assigned quote number) for #3 as I used for #2 because all quote items have the same new quote number, but the quote item other are associated with more than one quote item ID. If I can run the SQL for each quote item ID, this problem goes away. Not sure if that is clear or not.

    Perhaps there is an easier way to do this. I tend to make my own life difficult... Any help would be much appreciated, I have spent way too much time on this already.

  6. #6
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    DonnaA

    Opino como Mark,
    Si tu Subformulario esta activado tenes que poder acceder a los datos
    del registro que esta activo en el Subformulario..
    Si asi no anda, manda una pequeña de tu programa para ejecutarlo
    y ver que esta pasando.

    Saludos Norberto
    Saludos
    Norberto

Posting Permissions

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