By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 2,140 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

Refreshing problem

100+
P: 173
Ok, i have an add form that allows me to add site details......
on a different form i have a combobox from which i select a site name and it brings up the details.....

once ive added new details... i need to close the database down and go back into it for it to appear in the combobox??? ergghhh :(

when i add it from the add form, why cant it straight away show in the combobox???

ive added some requeries to my code below. (please note there are a few comboboxes on that form)

Combo2 searches sites by name and only shows live or pending
Combo22 searches sites by telephone numbers
Combo3 searches sites by names and only shows cancelled lines

WHAT SHALL I DO??? CAN SOMEONE LOOK AT MY CODE???

Expand|Select|Wrap|Line Numbers
  1. Private Sub add_Click()
  2.  Dim strSQL As String
  3.  DoCmd.SetWarnings False
  4.  Dim strmsg
  5.  strmsg = "Are you sure you want to add " & site & " to the table?"
  6.  
  7. If MsgBox(strmsg, vbYesNo) = vbYes Then
  8.  
  9.  strSQL = "INSERT INTO tab_data ([product], [provider], [site], [tel], [address_1], [address_2], [address_3], [postcode], [ip], [username], [password], [use], [type], [status], [notes], [line_provider], [line_status]) VALUES ('" & Me.Combo26 & "','" & Me.provider & "','" & Me.site & "','" & Me.tel & "','" & Me.address_1 & "','" & Me.address_2 & "','" & Me.address_3 & "','" & Me.postcode & "','" & Me.ip & "', '" & Me.username & "', '" & Me.password & "','" & Me.use & "','" & Me.Combo50 & "','" & Me.status & "','" & Me.notes & "','" & Me.line_provider & "','" & Me.line_status & "')"
  10.  
  11. ''Debug.Print strSQL
  12. [Forms]![Form1]![Combo2].Requery
  13. [Forms]![Form1]![Combo22].Requery
  14. [Forms]![Form1]![Combo3].Requery
  15.  DoCmd.RunSQL strSQL
  16.  DoCmd.SetWarnings True
  17.  End If
  18.  
  19.  
  20. End Sub
Feb 8 '07 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,315
The problem is that your SQL Insert is after your requeries. What's happening is it requeries and then it inserts. Move your insert up.
Feb 8 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.