If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Update a field in a query based on a user input
Hello
Can anybody help me to update a field in a query based on a user input? I declared an integer variable, intNum. The user input a number through use of an inputbox intNum = val(inputbox("Enter the correct number")) I run a query, qrySelectMember, to select a record from a table, tblMember. I want to update a tblMember field, SeatNumber, for the selected record whent the user click a command button, cmdUpdateSeatNumber. Any help will be appreciated, TIA, RT |
#2
|
|||
|
|||
RT,
How do you know what the current record is, I assume that the query or table that is the recordsource for your form has an ID field of some sort? You indicate you have a query, and a variable, why would you use in inputbox rather than a textbox on your form? The SQL for a query which is run from a command button on a form, containing a control that contains the seat number (txtSeatNumber), and where the forms recordsource contains an ID field would look something like: UPDATE tblMember SET SeatNumber = me.txtSeatNumber WHERE tblMember.ID = me.ID HTH Dale "RT" wrote in message ... Hello Can anybody help me to update a field in a query based on a user input? I declared an integer variable, intNum. The user input a number through use of an inputbox intNum = val(inputbox("Enter the correct number")) I run a query, qrySelectMember, to select a record from a table, tblMember. I want to update a tblMember field, SeatNumber, for the selected record whent the user click a command button, cmdUpdateSeatNumber. Any help will be appreciated, TIA, RT |
#3
|
|||
|
|||
On Mon, 4 Jul 2005 17:26:01 -0700, "RT"
wrote: Hello Can anybody help me to update a field in a query based on a user input? I declared an integer variable, intNum. The user input a number through use of an inputbox intNum = val(inputbox("Enter the correct number")) I run a query, qrySelectMember, to select a record from a table, tblMember. I want to update a tblMember field, SeatNumber, for the selected record whent the user click a command button, cmdUpdateSeatNumber. Any help will be appreciated, TIA, RT Whoa. You're taking five steps to do what can be done in two! UPDATE tblMember SET SeatNumber = Forms!frmYourForm!txtSeatNumber; Enter the seat number in the textbox txtSeatNumber and execute this query (in the command button's Click event or in txtSeatNumber'sAfterUpdate event). No prompt, very little code needed! One question though: is a seat number a proper attribute of a Member table? Does a member have one, and only one, seat? John W. Vinson[MVP] |
#4
|
|||
|
|||
Thanks, Dale! Both codes from you and John work correctly.
"Dale Fye" wrote: RT, How do you know what the current record is, I assume that the query or table that is the recordsource for your form has an ID field of some sort? You indicate you have a query, and a variable, why would you use in inputbox rather than a textbox on your form? The SQL for a query which is run from a command button on a form, containing a control that contains the seat number (txtSeatNumber), and where the forms recordsource contains an ID field would look something like: UPDATE tblMember SET SeatNumber = me.txtSeatNumber WHERE tblMember.ID = me.ID HTH Dale "RT" wrote in message ... Hello Can anybody help me to update a field in a query based on a user input? I declared an integer variable, intNum. The user input a number through use of an inputbox intNum = val(inputbox("Enter the correct number")) I run a query, qrySelectMember, to select a record from a table, tblMember. I want to update a tblMember field, SeatNumber, for the selected record whent the user click a command button, cmdUpdateSeatNumber. Any help will be appreciated, TIA, RT |
#5
|
|||
|
|||
Thanks, John! Both codes from you and Dale work correctly. To answer your
question, the system has three simple tables: tblMember has demographic information of the members. tblEvent has event's information. tblReservation is the junction table between tblMember and tblEvent. SeatNumber is one of the fields in tblReservation. If a member reserves three tickets, then the operator will find a consecutive open seats for the member. If consecutive seats are not available, then individual seats must be assigned to the member. Thanks again for your help. RT "John Vinson" wrote: On Mon, 4 Jul 2005 17:26:01 -0700, "RT" wrote: Hello Can anybody help me to update a field in a query based on a user input? I declared an integer variable, intNum. The user input a number through use of an inputbox intNum = val(inputbox("Enter the correct number")) I run a query, qrySelectMember, to select a record from a table, tblMember. I want to update a tblMember field, SeatNumber, for the selected record whent the user click a command button, cmdUpdateSeatNumber. Any help will be appreciated, TIA, RT Whoa. You're taking five steps to do what can be done in two! UPDATE tblMember SET SeatNumber = Forms!frmYourForm!txtSeatNumber; Enter the seat number in the textbox txtSeatNumber and execute this query (in the command button's Click event or in txtSeatNumber'sAfterUpdate event). No prompt, very little code needed! One question though: is a seat number a proper attribute of a Member table? Does a member have one, and only one, seat? John W. Vinson[MVP] |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Many-to-many implementation problem | Al Williams | Database Design | 15 | April 29th, 2005 05:19 PM |
Update field value automatically based on subform | Sammie | Using Forms | 0 | February 11th, 2005 09:49 PM |
update queries and forms | Mary Pode | Database Design | 16 | February 2nd, 2005 05:25 PM |
Office 2003 installation problem, log file attached.... | Ryan | Setup, Installing & Configuration | 0 | January 20th, 2005 06:57 PM |
Here's a shocker | Mike Labosh | General Discussion | 2 | October 26th, 2004 05:04 PM |