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
603 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now