delete from combo box

  • Thread starter peljo via AccessMonster.com
  • Start date
P

peljo via AccessMonster.com

Why deletion from a combo box is not working ? I have a control in my form
called productid. In the onClick event of this control i have :
Dim StrSQL As String
StrSQL = "DELETE * FROM [order details1] WHERE ProductID = " & Me!productid &
";"
CurrentDb.Execute StrSQL

When i change the control from a text box into a combo box nothing happens
and no deletion occurs.However when i change again from como box into a text
box the deletion is OK. How can i make the onclick event work also with the
combo box ?
 
J

Jeanette Cunningham

Hi Peljo,

One way to find out why it doesn't work:

After the strSQL line in your code but before the CurrentDb.Execute StrSQL
line type this:
debug.print "productid: " & Me!productid
debug.print "StrSQL: " & StrSQL

Run your code
Go Ctl + G to open the immediate window

If the productid is null, we can help you to get the productid from the
combobox.
The productid needs to be in the bound column of your combobox

If the productid has a value, then copy the SQL string from the immediate
window into a new query in SQL view.
Switch the query to datasheet view as a way to check if there is any problem
with the query string.

Jeanette Cunningham
 
J

Jeff Boyce

I'm not sure I'm following completely, but it sounds like the combobox
doesn't "know" that the item was deleted.

Perhaps, in the Click event, you could add:

Me.MyComboBox.Requey

after the deletion ... this should refill the combobox list.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
 
J

Jeff Boyce

oops, that should have been

Me.MyComboBox.Requery

Jeff

Jeff Boyce said:
I'm not sure I'm following completely, but it sounds like the combobox
doesn't "know" that the item was deleted.

Perhaps, in the Click event, you could add:

Me.MyComboBox.Requey

after the deletion ... this should refill the combobox list.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/


peljo via AccessMonster.com said:
Why deletion from a combo box is not working ? I have a control in my form
called productid. In the onClick event of this control i have :
Dim StrSQL As String
StrSQL = "DELETE * FROM [order details1] WHERE ProductID = " & Me!productid &
";"
CurrentDb.Execute StrSQL

When i change the control from a text box into a combo box nothing happens
and no deletion occurs.However when i change again from como box into a text
box the deletion is OK. How can i make the onclick event work also with the
combo box ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top