• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 614
  • Last Modified:

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

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
mindserve
Asked:
mindserve
  • 4
  • 3
  • 2
1 Solution
 
CSLEEDSCommented:
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
 
abdulhameedsCommented:
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
 
abdulhameedsCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mindserveAuthor Commented:
Hi,
It's a Data Combo not a combo box. Would this be the same solution for the "Data" combo?
0
 
abdulhameedsCommented:
sorry i read it wrong !!!!!!!
sry again
0
 
mindserveAuthor Commented:
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
 
CSLEEDSCommented:
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
 
mindserveAuthor Commented:
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
 
mindserveAuthor Commented:
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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now