Update a table with a selected Field in a combo Box

Tom d

Member
Local time
Today, 11:14
Joined
Jul 12, 2022
Messages
106
On the Book Update/Delete form, I want the On Change Event Of the Authors Combo Box to update the BookLibrary TBL field “AuthorsID” when the user selects a new Author
 

Attachments

UPDATE which record? Need to know which BookID.

Why use UNBOUND form?

Suggest you review http://allenbrowne.com/ser-62.html

Might also look at MS Lending Library template database.

Might want to change name of combo from AuthersNameCBO to AuthorsNameCBO.
Advise not to use spaces in naming convention. Better would be BookLibrary_TBL.
 
UPDATE which record? Need to know which BookID.

Why use UNBOUND form?

Suggest you review http://allenbrowne.com/ser-62.html
On the Book Update/Delete form, I want the On Change Event Of the Authors Combo Box to update the BookLibrary TBL field “AuthorsID” when the user selects a new Author
The RecordID is in BookNameCBO Column 1
Might also look at MS Lending Library template database.

Might want to change name of combo from AuthersNameCBO to AuthorsNameCBO.
Advise not to use spaces in naming convention. Better would be BookLibrary_TBL.
The BookID is the one Selected in BookNameCBO Column 1
UPDATE which record? Need to know which BookID.

Why use UNBOUND form?

Suggest you review http://allenbrowne.com/ser-62.html

Might also look at MS Lending Library template database.

Might want to change name of combo from AuthersNameCBO to AuthorsNameCBO.
Advise not to use spaces in naming convention. Better would be BookLibrary_TBL.
The BookID is the one Selected in BookNameCBO Column(1)
UPDATE which record? Need to know which BookID.

Why use UNBOUND form?

Suggest you review http://allenbrowne.com/ser-62.html

Might also look at MS Lending Library template database.

Might want to change name of combo from AuthersNameCBO to AuthorsNameCBO.
Advise not to use spaces in naming convention. Better would be BookLibrary_TBL.
The BookID is the one Selected in BookNameCBO The first Column. The Form Record Source Is BookLibrary TBL
UPDATE which record? Need to know which BookID.

Why use UNBOUND form?

Suggest you review http://allenbrowne.com/ser-62.html

Might also look at MS Lending Library template database.

Might want to change name of combo from AuthersNameCBO to AuthorsNameCBO.
Advise not to use spaces in naming convention. Better would be BookLibrary_TBL.

UPDATE which record? Need to know which BookID.

Why use UNBOUND form?

Suggest you review http://allenbrowne.com/ser-62.html

Might also look at MS Lending Library template database.

Might want to change name of combo from AuthersNameCBO to AuthorsNameCBO.
Advise not to use spaces in naming convention. Better would be BookLibrary_TBL.
The RecordID is in BookNameCBO Column 1
UPDATE which record? Need to know which BookID.

Why use UNBOUND form?

Suggest you review http://allenbrowne.com/ser-62.html

Might also look at MS Lending Library template database.

Might want to change name of combo from AuthersNameCBO to AuthorsNameCBO.
Advise not to use spaces in naming convention. Better would be BookLibrary_TBL.
The RecordID is in BookNameCBO Column 1. This Tread is not complete!
On the Book Update/Delete form, I want the On Change Event Of the Authors Combo Box to update the BookLibrary TBL field “AuthorsID” when the user selects a new Author
 
I would expect the AfterUpdate event, not the Change?
This will be the thread that you say you cannot post on?
 
The BookID is the one Selected in BookNameCBO Column 1

The BookID is the one Selected in BookNameCBO Column(1)

The BookID is the one Selected in BookNameCBO The first Column. The Form Record Source Is BookLibrary TBL



The RecordID is in BookNameCBO Column 1

The RecordID is in BookNameCBO Column 1. This Tread is not complete!
The RecordID is in BookNameCBO Column 1. This Tread is not complete!
 
Posting duplicate posts is not going to help anyone. :(
 
The RecordID is in BookNameCBO Column 1. This Tread is not complete!
Marked it unsolved but it keeps saying it is solved
For some reason I can now post replies
 
Last edited:
Okay, I see now that the form does have a Record Source but there are no BOUND controls for displaying record data. Updating a record can be accomplished more than one way:

1. SQL
If Not IsNull(Me.BookNameCBO) And Not IsNull(Me.AuthersNameCBO Then
CurrentDb.Execute "UPDATE [BookLibrary TBL] SET AuthorID=" & Me.AuthersNameCBO & " WHERE BookID=" & Me.BookNameCBO
End If

2. use code to locate record in form's recordset then directly set value of field.

3. add bound controls to form, use code to locate record and display on form, author combobox is bound to field, user selects author
 
Okay, I see now that the form does have a Record Source but there are no BOUND controls for displaying record data. Updating a record can be accomplished more than one way:

1. SQL
If Not IsNull(Me.BookNameCBO) And Not IsNull(Me.AuthersNameCBO Then
CurrentDb.Execute "UPDATE [BookLibrary TBL] SET AuthorID=" & Me.AuthersNameCBO & " WHERE BookID=" & Me.BookNameCBO
End If

2. use code to locate record in form's recordset then directly set value of field.

3. add bound controls to form, use code to locate record and display on form, author combobox is bound to field, user selects author
Run time error 3061Too few parameters. Expected 1
 
Put the SQL into a string variable and Debug.Print that variable and copy and paste that output back here.

Note: I have going to have that statement on my gravestone. :)
 
Put the SQL into a string variable and Debug.Print that variable and copy and paste that output back here.

Note: I have going to have that statement on my gravestone. :)
Thanks for all your help. This tread is now complete.
 

Users who are viewing this thread

Back
Top Bottom