D
David Brown
I have a block of code (below) that populates a combo box using the after
update event of another combo box. The code runs fine on my system but on
some machines it won't run. I am using Access 2002, the machine in question
is using Access 2000. Both machines run XP. Please take a look at my code
and fill me in on any possible problems. Also, could this be some sort of
setting or security issue in Access or XP? Finally, if there is another
group I need to post this sort of thing to, please let me know.
Thanks,
David Brown
Private Sub cboSiteID_AfterUpdate()
'populate the patient field based on site ID
Dim MyTempCount As Integer
Dim cnn1 As New ADODB.Connection
Dim cmd1 As New ADODB.Command
Dim SQLString1 As String
Dim rst1 As ADODB.Recordset
Dim MySite As Integer
Dim FirstTime As Integer
MySite = Me.cboSiteID
'Remove values from the current list
MyTempPat = Me.cboPatientName.ListCount - 1
If MyTempPat > -1 Then
For x = MyTempPat To 0 Step -1
Me.cboPatientName.RemoveItem (x)
Next
End If
'Open a connection to the current project
Set cnn1 = CurrentProject.Connection
'Create query strings
SQLString1 = "SELECT * FROM qry_ActivePatients WHERE Pat_SiteID = " & MySite
Set cmd1 = New ADODB.Command
With cmd1
.ActiveConnection = cnn1
.CommandText = SQLString1
.Execute
End With
Set rst1 = New ADODB.Recordset
rst1.Open cmd1
While Not rst1.EOF
MyName = rst1(0) & ";" & rst1(1) & ";" & rst1(2) & ";" & rst1(3)
Me.cboPatientName.AddItem Item:=MyName
rst1.MoveNext
Wend
Me.cboPatientName.Enabled = True
Me.lblTip.Visible = True
Me.lblTipContent.Visible = True
End Sub
update event of another combo box. The code runs fine on my system but on
some machines it won't run. I am using Access 2002, the machine in question
is using Access 2000. Both machines run XP. Please take a look at my code
and fill me in on any possible problems. Also, could this be some sort of
setting or security issue in Access or XP? Finally, if there is another
group I need to post this sort of thing to, please let me know.
Thanks,
David Brown
Private Sub cboSiteID_AfterUpdate()
'populate the patient field based on site ID
Dim MyTempCount As Integer
Dim cnn1 As New ADODB.Connection
Dim cmd1 As New ADODB.Command
Dim SQLString1 As String
Dim rst1 As ADODB.Recordset
Dim MySite As Integer
Dim FirstTime As Integer
MySite = Me.cboSiteID
'Remove values from the current list
MyTempPat = Me.cboPatientName.ListCount - 1
If MyTempPat > -1 Then
For x = MyTempPat To 0 Step -1
Me.cboPatientName.RemoveItem (x)
Next
End If
'Open a connection to the current project
Set cnn1 = CurrentProject.Connection
'Create query strings
SQLString1 = "SELECT * FROM qry_ActivePatients WHERE Pat_SiteID = " & MySite
Set cmd1 = New ADODB.Command
With cmd1
.ActiveConnection = cnn1
.CommandText = SQLString1
.Execute
End With
Set rst1 = New ADODB.Recordset
rst1.Open cmd1
While Not rst1.EOF
MyName = rst1(0) & ";" & rst1(1) & ";" & rst1(2) & ";" & rst1(3)
Me.cboPatientName.AddItem Item:=MyName
rst1.MoveNext
Wend
Me.cboPatientName.Enabled = True
Me.lblTip.Visible = True
Me.lblTipContent.Visible = True
End Sub