473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Combobox Selection not updating form bound fields

Dear Bytes community,

Framework: I have created a form using the "Form Design" tool. On the form property sheet, it was added to the Record Source the table which contained the fields that I wanted to update/add.
The fields from the table were introduced in the form using the "Add Existing Fields" button.
In the next step, in order to have the fields populated by a combobox selection, I added a combobox with the option "Find a record on my form based on the value I selected in my combobox.".

Problem: After selecting a combobox value, the fields in the form didn't update themselves.

Question: Any idea why this fields don't update?

Since Access already have the connections made internally, I think there should be a clenear way of accomplishing the goal without using Column property, DlookUp, subforms or recordset code (I thought the one implemented would be the faster way but it is not working).

Thank you very much in advance for your time and help.

Best regards
Jul 21 '17 #1

✓ answered by PhilOfWalton

Whoops, sorry, posted in error

Modify the subroutine to this
Expand|Select|Wrap|Line Numbers
  1. Private Sub cbTag_AfterUpdate
  2.  
  3.     Dim Fltr as String
  4.     Fltr = "ValveID = " & cbTag
  5.     Me.Filter = Fltr
  6.     Me.FilterOn = True
  7.  
  8. End Sub
  9.  
There will be other problems but one thing at a time

Phil

10 4114
PhilOfWalton
1,430 Expert 1GB
'Fraid that's the problem using Wizards.

So several questions.
What is the RowSource of your Combo Box, which is the Bound Column, How many columns and how wide are they?

Can you let us have the names of all the fields on your form.

Phil
Jul 21 '17 #2
PhilOfWalton,

Thank you for your answer. I will put here a sample of the table and form (in order to be easier to debug).
In the next image we can see the names of all fidels of my form:



Relatively to the Combobox/form, it is possible to analyse the details in the next image:



The form has Valves table as record source.

Thank you!
Jul 21 '17 #3
PhilOfWalton
1,430 Expert 1GB
OK, you need a bit of code to get this to work (Most of your Combo boxes to find a record will work the same way).

You also need on your form a field called ID bound to the ID in your table. Incidentally, for clarity, I would rename both the table and control ValveID (The default of Access is to name the first line of all your tables "ID", and it gets very confusing.)

Go to the Event Tab on the Property Sheet. On the After Update , if you type a square bracket [, it will change this to [Event Procedure].
Click on this line and 3 dots ... will appear at the end of the line. Click on these.

You are now writing code.
It will say at this point
Expand|Select|Wrap|Line Numbers
  1. Private Sub cbTag_AfterUpdate
  2.  
  3. End Sub
  4.  
Scroll to the top of the code page and ensure that it says

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
Go back to where it starts with Private Sub cbTag_AfterUpdate

Make the code read as follows

Expand|Select|Wrap|Line Numbers
  1. Private Sub cbTag_AfterUpdate
  2.  
  3.     Me.ValveID.SetFocus      ' Moves the cursor to the ValveID Control
  4.     DoCmd.FindRecord cbTag
  5.  
  6. End Sub
  7.  
Yet another "Incidentally", if you get a number of valves from the same manufacturer, you should have a table of manufacturers. That way their name is only entered once in the whole database, and no chance of misspelling it.

Phil
Jul 21 '17 #4
PhilOfWalton,

Thank you for your repply and very detailed explanation. It is always good to learn new programming methods.
After implementing your routine, error 3021 (No current record) appeared.
Also, ValveID is always giving me numbers (check image)


https://www.dropbox.com/s/45ijj37o0r...r3021.png?dl=0

Well, the error is eliminated if the routine
Expand|Select|Wrap|Line Numbers
  1. 'Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.     'If Not BotaoGravar Then
  3.         'Cancel = True 'Se o botão gravar não tiver sido ativado, então o formulário não atualiza informação para a tabela
  4.     'End If
  5. 'End Sub
is eliminated. I use this routine to update the Data to the table via the bound fields using a Save button.

Nevertheless, the fields are not updating. I think this is happening because the ValveID field is not being updated after the TAG selection.
Best regards.
Jul 21 '17 #5
PhilOfWalton
1,430 Expert 1GB
I suspect your problem is that as soon as you Load the form, you run Sub_Limpar_Click which clears everything out.

Sorry, I don't speak Portuguese so I have to translate your comments

So if you only want to see the record that you find in the cbTag Combo Box, and not be able to scroll through the records we need a different technique.
Firstly comment out the line Limpar_Click in your Sub Form_Load procedure

Then modify the Subroutine I gave you to this

Expand|Select|Wrap|Line Numbers
  1. Private Sub cbTag_AfterUpdate
  2.  
  3.  
  4.     Me.ValveID.SetFocus      ' Moves the cursor to the ValveID Control
  5.     DoCmd.FindRecord cbTag
  6.  
  7. End Sub
  8.  
Jul 21 '17 #6
PhilOfWalton
1,430 Expert 1GB
Whoops, sorry, posted in error

Modify the subroutine to this
Expand|Select|Wrap|Line Numbers
  1. Private Sub cbTag_AfterUpdate
  2.  
  3.     Dim Fltr as String
  4.     Fltr = "ValveID = " & cbTag
  5.     Me.Filter = Fltr
  6.     Me.FilterOn = True
  7.  
  8. End Sub
  9.  
There will be other problems but one thing at a time

Phil
Jul 21 '17 #7
PhilOfWalton,

Thank you very much. The code is working perfectly!!
You have been excelent. Now I just have to solve some incompatibilities with my code.

Amazing!! Just what I wanted!
Jul 21 '17 #8
PhilOfWalton
1,430 Expert 1GB
Come back if you get stuck

Phil
Jul 21 '17 #9
PhilOfWalton,

I have one more question. Should I create a new topic?
Jul 22 '17 #10
PhilOfWalton
1,430 Expert 1GB
I think that would be best.
Jul 22 '17 #11

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

Similar topics

2
by: aaa | last post by:
Hello to all, In an application under VB6, I need to fill some ComboBoxes with data. However, I don't know in advance how many ComboBoxes I will need. I could of course create many (maybe 15 or...
11
by: billa856 | last post by:
Hi, I have project in MS Access.In that I have one form in which there is one combobox .I want to know when I select an item from that combobox and click on submit button then it should open a...
3
by: beemomo | last post by:
I have two tables - 'Client' and 'Company', and two forms, 'Client' and 'Company', the relationship between two table is 1:many where a company can have one or more client but each of the client...
2
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi All! I am with a situation where I am not getting the right updating to the form's fields. The situation is the following one: I have one combobox and one textbox. I am using the...
4
by: Mtek | last post by:
Hi, We have a combo box on our page, which gets populated via a MySQL Query in PHP. What we want to do is to print the values on the page in a table that correspond the to selection from the...
1
by: BarbieJo | last post by:
Using Access 2007 I want all the bound fields in my form to be locked until a command button is clicked. I have already tried locking the form through the OnLoad property using the following code:...
4
by: Organizer | last post by:
I am using Microsoft Access 2007. I have a list in a dropdown combobox (Field_One) in a form (Form_One). Users have the option to click a button if the item they need does not appear in the combobox,...
1
by: Emily Walshaw | last post by:
I'm sorry, I know this has been asked a million times, but am completely new to access and need idiot proof help. I have a database and I am struggling to get a field to update based on a combobox...
0
by: Moorthi chinna | last post by:
how to reload combobox in datagridview based on combobox selection in datagridview?
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.