Changing Record using value selected in combo box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • copewithit
    New Member
    • Jul 2007
    • 6

    #1

    Changing Record using value selected in combo box

    Hi all,

    I'm trying to modify a record (in this case the name associated with the record) to a new name selected by the user in a combo box. Right now I have Single Form with a subform in datasheet view. One of the fields of the subform is a checkbox which allows the user to select which record(s) they want to change the name of. On the single form I have a combo box that allows the user to select the name they want to replace the selected record with.

    I think VB is the way to go becuase I've tried Macro's and the setValue option and I have trouble with logic and only modifying the values that have been selected.

    I think I want to do something like
    Code:
     Inventory.Name WHERE Delete = Forms!Switch_Name!Name;
    Inventory is the table where the records are, and Name is the field I want to update. Delete is the name of the field of the checkbox. I think my methods are right, just my syntax is off. I'm not too sure with VB.

    Thanks for all your help!
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    Originally posted by copewithit
    Hi all,

    I'm trying to modify a record (in this case the name associated with the record) to a new name selected by the user in a combo box. Right now I have Single Form with a subform in datasheet view. One of the fields of the subform is a checkbox which allows the user to select which record(s) they want to change the name of. On the single form I have a combo box that allows the user to select the name they want to replace the selected record with.

    I think VB is the way to go becuase I've tried Macro's and the setValue option and I have trouble with logic and only modifying the values that have been selected.

    I think I want to do something like
    Code:
     Inventory.Name WHERE Delete = Forms!Switch_Name!Name;
    Inventory is the table where the records are, and Name is the field I want to update. Delete is the name of the field of the checkbox. I think my methods are right, just my syntax is off. I'm not too sure with VB.

    Thanks for all your help!
    It sounds like you want to delete the checked item, not update it.

    Delete * From Inventory Where Inventory.Name = Me!Switch_Name. Form!Name And Delete = True

    Comment

    • copewithit
      New Member
      • Jul 2007
      • 6

      #3
      Well if I were to delete the record, then I would be loosing the information. I'm more interested in modifying the checked records, and updating the name field in each one.

      The example syntax does help, but I'm still not sure on how to modify a certain field that has been checked in a subform datasheet.

      Comment

      • puppydogbuddy
        Recognized Expert Top Contributor
        • May 2007
        • 1923

        #4
        Originally posted by copewithit
        Well if I were to delete the record, then I would be loosing the information. I'm more interested in modifying the checked records, and updating the name field in each one.

        The example syntax does help, but I'm still not sure on how to modify a certain field that has been checked in a subform datasheet.

        If you want to update (and not delete), try the syntax below, but keep in mind I am assuming that Switch_Name is the name of your subform control on the main form. I used Me to reference your Main form:

        Update Inventory Set Inventory.Name = Me!Switch_Name. Form!Name Where Delete = True

        Comment

        • copewithit
          New Member
          • Jul 2007
          • 6

          #5
          Thanks! The SQL Update command really helped. A quick note, if you want to update more then one field you just use a coma inbetween update expressions. Thanks again!

          Comment

          Working...