11-05-2019, 08:07 PM
|
#1
|
Newly Registered User
Join Date: Apr 2019
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
|
Update Query Via FORM Input. Please advice
Dear Experts,
First Thanking you in Advance for the help. I am new to Ms Access. Need your guidance in "Update Query".
I am trying to update table (EmployeeDetails)from another table(Sheet1). I have made a FORM(QueryForm) where there is Combobox listing down what to Update. For Example "FIRST NAME" but how to add this Combobox input to "UPDATE QUERY".
Note :- I know the query should be [Sheet1].[FIRST NAME] in "Update to).
Need you help in how should i get First Name via FORM to "Update to". Please advice
|
|
|
11-05-2019, 08:14 PM
|
#2
|
AWF VIP
Join Date: Mar 2014
Location: The Great Land
Posts: 2,476
Thanks: 0
Thanked 577 Times in 573 Posts
|
Re: Update Query Via FORM Input. Please advice
Do you want to use VBA? Something like:
CurrentDb.Execute "UPDATE EmployeeDetails Set [" & Me.combobox & "] = '" & Me.textbox & "'"
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
|
The Following User Says Thank You to June7 For This Useful Post:
|
|
11-05-2019, 08:17 PM
|
#3
|
Newly Registered User
Join Date: Apr 2019
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
|
Re: Update Query Via FORM Input. Please advice
I can use it , but you need to guide me on that. Also I have many fields to update like Father's name, DOB, DOj, etc. do i have to create vba for each of this?
need you advice. thanks for your response
|
|
|
11-05-2019, 08:18 PM
|
#4
|
AWF VIP
Join Date: Mar 2014
Location: The Great Land
Posts: 2,476
Thanks: 0
Thanked 577 Times in 573 Posts
|
Re: Update Query Via FORM Input. Please advice
Happy to give advice but don't have enough info.
How should Sheet1 data be utilized? Are there unique identifier fields that link these tables? Post some sample data to show table structures.
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
|
11-05-2019, 08:29 PM
|
#5
|
Newly Registered User
Join Date: Apr 2019
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
|
Re: Update Query Via FORM Input. Please advice
Sheet1 is the Table Where All Data has to be imported to EmployeeDetails.
I am using Update Query to Import Data for above. Where i have to type manually all fields i.e. where to update "Update To".
TEST Query :- its the query created for update via Form
Query Form :- Its the Form where There is Drop Down items from EmployeeDetails.
|
|
|
11-05-2019, 08:46 PM
|
#6
|
AWF VIP
Join Date: Mar 2014
Location: The Great Land
Posts: 2,476
Thanks: 0
Thanked 577 Times in 573 Posts
|
Re: Update Query Via FORM Input. Please advice
Yes, in UPDATE query you have to specify each field you want to update and the field to pull value from in the design grid. Include as many fields as you want in the UPDATE design. So why would user be selecting a field for update?
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
|
11-05-2019, 08:50 PM
|
#7
|
Newly Registered User
Join Date: Apr 2019
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
|
Re: Update Query Via FORM Input. Please advice
I want that field "Update to" to pull data from FORM's combobox selection as INPUT to "Update to". So instead of typing Sheet1.FIRST NAME, i want Sheet1 and FIRST NAME SHOULD be selected from Combobox and then run the query.
|
|
|
11-05-2019, 09:01 PM
|
#8
|
AWF VIP
Join Date: Mar 2014
Location: The Great Land
Posts: 2,476
Thanks: 0
Thanked 577 Times in 573 Posts
|
Re: Update Query Via FORM Input. Please advice
Sorry, but that isn't making sense. Since Sheet1.FirstName can only be under EmployeeDetails FirstName field and names on Field row in a query object cannot be dynamic, making criteria dynamic by selection in combobox serves no purpose. However, VBA can dynamically build SQL statement.
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
|
11-05-2019, 09:03 PM
|
#9
|
Newly Registered User
Join Date: Apr 2019
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
|
Re: Update Query Via FORM Input. Please advice
Ok,
can this help, if yes, let me know to use it,
Do you want to use VBA? Something like:
CurrentDb.Execute "UPDATE EmployeeDetails Set [" & Me.combobox & "] = '" & Me.textbox & "'"
|
|
|
11-05-2019, 09:20 PM
|
#10
|
AWF VIP
Join Date: Mar 2014
Location: The Great Land
Posts: 2,476
Thanks: 0
Thanked 577 Times in 573 Posts
|
Re: Update Query Via FORM Input. Please advice
Use query designer to build the SQL that joins tables so you can get correct syntax. Then copy/paste and make adjustments in VBA. Result should be something like:
CurrentDb.Execute "UPDATE EmployeeDetails INNER JOIN Sheet1 ON Sheet1.Code = EmployeeDetails.Code SET EmployeeDetails.[" & Me.combobox & "] = Sheet1.[" & Me.combobox & "]"
This assumes Sheet1 and EmployeeDetails field names are identical.
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
|
11-05-2019, 10:27 PM
|
#11
|
Newly Registered User
Join Date: Apr 2019
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
|
Re: Update Query Via FORM Input. Please advice
yes the Field names are same. i did some what like this. please guide me on VBA part.
UPDATE EmployeeDetails INNER JOIN Sheet1 ON EmployeeDetails.CODE = Sheet1.CODE SET;
in me.combobox do i have to write lable name.
|
|
|
11-05-2019, 10:36 PM
|
#12
|
AWF VIP
Join Date: Mar 2014
Location: The Great Land
Posts: 2,476
Thanks: 0
Thanked 577 Times in 573 Posts
|
Re: Update Query Via FORM Input. Please advice
Combobox would be a list of field names. Set combobox RowSourceType to Field List and RowSource to EmployeeDetails.
Your SQL statement is incomplete. Need to finish the SET clause as shown in my example. Use your combobox name.
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Last edited by June7; 11-06-2019 at 11:56 AM.
|
|
|
11-06-2019, 08:30 AM
|
#13
|
Super Moderator
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,316
Thanks: 15
Thanked 1,601 Times in 1,520 Posts
|
Re: Update Query Via FORM Input. Please advice
I'm going to ask a silly question.
Why are you using an update query instead of a bound form?
__________________
Bridge Players Still Know All the Tricks
|
|
|
11-06-2019, 10:17 PM
|
#14
|
Newly Registered User
Join Date: Apr 2019
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
|
Re: Update Query Via FORM Input. Please advice
Hello Pat,
I am new to access. I have to update record based on Employee Code. like vlookup in excel.
currently i have the update query which is working. but i need that query should look up on form for input and then run.
your advice will help if i am going wrong anywhere.
|
|
|
11-06-2019, 10:22 PM
|
#15
|
AWF VIP
Join Date: Mar 2014
Location: The Great Land
Posts: 2,476
Thanks: 0
Thanked 577 Times in 573 Posts
|
Re: Update Query Via FORM Input. Please advice
If you are importing data from Excel to edit existing records in Access, then an UPDATE query is needed.
I still don't understand why you want user to select field.
I have to ask - why is Excel even involved?
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
|
Thread Tools |
|
Display Modes |
Rate This Thread |
Linear Mode
|
|
All times are GMT -8. The time now is 11:30 PM.
|
|