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
604 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

895 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

18 Experts available now in Live!

Get 1:1 Help Now