Solved

How to update a "Data Combo" box when the data is entered to the database ( Access 2002) without a requery

Posted on 2008-06-23
9
607 Views
Last Modified: 2012-08-13
I have a data combo box and this is used for customer to lookup clients. When the add a new customer if I do not requery the database or refresh it then the newly added client does not show up in the data combo list. The users need to be able to add and remain on the newly added customer. How can I do this in vb 6?
0
Comment
Question by:mindserve
  • 4
  • 3
  • 2
9 Comments
 
LVL 4

Expert Comment

by:CSLEEDS
ID: 21852788
so u already have the code to populate the item in the combo box? then u just put the code to populate the combo box in the drop down event, so that every time when user want to choose a item from the list, the combo box will be populate with the latest updated records from database.


regards.
0
 
LVL 4

Expert Comment

by:abdulhameeds
ID: 21852883
in the lost_focus even of the combobox
u have to check the data in the text of the combo


combo1_lostfocus()
if combo1.text="" then exit sub
dim rs as recordset
dim sql as string
set rs= new recordset
sql="select * from table where Field_combo='" & combo1.text  &" '
rs.Open sql, db, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
'this data is exits so leave it or update it
db.exeute "update......"
else
'the data in the combo text not exit so u can insert it
db.execute "insert into .........."
end if

0
 
LVL 4

Expert Comment

by:abdulhameeds
ID: 21852889
sorry you have to put other hedden text box after the end if statment
textbox.text= combo1.text
you will make re fill to the combo
then transfer the new data to the combo
then
combo1.text = textbox.text


best regards
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 1

Author Comment

by:mindserve
ID: 21854562
Hi,
It's a Data Combo not a combo box. Would this be the same solution for the "Data" combo?
0
 
LVL 4

Expert Comment

by:abdulhameeds
ID: 21854586
sorry i read it wrong !!!!!!!
sry again
0
 
LVL 1

Author Comment

by:mindserve
ID: 21855981
Sorry, for some reason that's not working at all for me.
I get a null error... It is saving to the database but just not showing in the data combo after the "Save" or update until the database is requeried or refreshed. This causes a problem since the user cannot remain on the customer and they need to since they then have to add a ticket to this customer ( it's a POS program)
0
 
LVL 4

Expert Comment

by:CSLEEDS
ID: 21861961
so u are using a combo box that bound to a data source?? then u are about to populate the data combo without requery the db? then what i suggest is do something with your data source, try if u can add the record into the combo box data source manually so that latest inserted record can shown in the combo.

regards.
0
 
LVL 1

Author Comment

by:mindserve
ID: 21864222
It's a "Data Combo" not combo box. But after the new record is added to the screen and I click on the Data combo I don't see the newly added customer..however; I see a space for it...I can click below the last entry to highlight it, and it appears that something should or wants to be there. I don't want to requery the database as that moves off the record and back to the first record. I need to stay on the current record.
I tried Move(0) but that didn't work either.  


How do I manually add the record to the combo box source manually..........??
0
 
LVL 1

Accepted Solution

by:
mindserve earned 0 total points
ID: 22018781
I found a very simple solution that does work. All you need to do is to refresh the control and it updates with the item while still holding the bookmark. CBOCategories is the DataCombo

 adoPrimaryRS.Bookmark = CBOCategories.SelectedItem
  CBOCategories.Refresh
adoPrimaryRS.Bookmark = CBOCategories.SelectedItem
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question