By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,667 Members | 2,611 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,667 IT Pros & Developers. It's quick & easy.

Changing Record using value selected in combo box

P: 6
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
Expand|Select|Wrap|Line Numbers
  1.  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!
Jul 13 '07 #1
Share this Question
Share on Google+
4 Replies


puppydogbuddy
Expert 100+
P: 1,923
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
Expand|Select|Wrap|Line Numbers
  1.  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
Jul 13 '07 #2

P: 6
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.
Jul 13 '07 #3

puppydogbuddy
Expert 100+
P: 1,923
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
Jul 13 '07 #4

P: 6
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!
Jul 13 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.