Results 1 to 4 of 4
  1. #1
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Recordset Coding Reference (A2k SR1)

    The below code works.

    <pre>For Each varitem In ctl.ItemsSelected
    With rst
    .AddNew
    !TempPrimary= ctl.Column(0, varitem)
    .Update
    End With
    Next varitem</pre>



    However, earlier in the code I have the following:

    Dim FieldToModify as String
    FieldToModify = TempPrimary

    I want to replace TempPrimary in the following with FieldtoModify

    !TempPrimary= ctl.Column(0, varitem) However,

    with !FieldToModify = ctl.Column(0,varitem) but it doesn't work. Also tried
    with !&FieldToModify& = ctl.Column(0,varitem) but get errors

    Tried various other combinations.

    Is this possible?
    Regards,

    Gary
    (It's been a while!)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Recordset Coding Reference (A2k SR1)

    Use .Fields(FieldToModify) = ...

    I hope you actually had FieldToModify = "TempPrimary" (note the quotes)

  3. #3
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Recordset Coding Reference (A2k SR1)

    Thanks Hans. I will give this a try.

    PS - Field to modify is actually set as follows:

    <pre>'Set LBoxName to the name of table based on list box selected
    LBoxName = Screen.ActiveControl.Name

    'Create Field to Modify - i.e., TempPrimary
    FieldtoModify = "Temp" & Right(LBoxName, Len(LBoxName) - 4)</pre>

    Regards,

    Gary
    (It's been a while!)

  4. #4
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Recordset Coding Reference (A2k SR1)

    Hans,

    Works like a charm. Thanks once again for the help. <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>
    Regards,

    Gary
    (It's been a while!)

Posting Permissions

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