?
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
Medium Priority
?
612 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Progress
Introduction to Processes

752 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