O
OMS
Hi,
I've inherited this 2003 code that needs to work in 2000 runtime. The main
sticking point is the AddItem in a listbox. I've tried a few things but the
closest I get is it populating only one row in the box with all items. I've
included the code with remmed lines to give you a better idea of where I
was, where I am and where I need to be. What am I doing wrong? Oh, please do
reply telling me AddItem doesn't work in 2000. I know that, I just want the
same or similar effect and really don't know enough lingo to reference
correctly. Like legacy coding or some such thing.
Hope you can help.
Thanks, OMS
Private Sub Form_Load()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim frm As Form, ctl As Control
Dim varItm As Variant
Dim strSQL As String
Dim strItem As String
Dim strPMP As String
Dim strITN As String
Dim strNurSta As String
Dim strCaption As String
Dim RowItem As String
Dim RowList As String
Set frm = Forms!usr_frm_SelectMAR
Set ctl = frm!lstPatient
strSQL = "SELECT PHM_ORDERS.GENERIC_NAME, PHM_ORDERS.BRAND_NAME, " &_
"PHM_ORDERS.DOSE, PHM_ORDERS.ROUTE, Val([PMP]) AS Mpmp," & _
"IIf(IsNull([DESCRIPTION]),Trim([LATIN_DIR_ABBR]),Trim([DESCRIPTION]))
AS modSig " & _
"FROM PHM_ORDERS LEFT JOIN tblLatin ON PHM_ORDERS.LATIN_DIR_ABBR
= tblLatin.[LATIN CODE] " & _
"WHERE PHM_ORDERS.ITN = """ & m_strITN & """ " & _
"AND PHM_ORDERS.MED_IV <> ""S"" " & _
"AND PHM_ORDERS.SCH_PRN_TKH = ""SCHEDULED"" " & _
"AND PHM_ORDERS.STOPPED = ""NO"" " & _
"ORDER BY Val([PMP]) DESC ;"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)
Do Until rst.EOF
' strItem = Trim(rst.Fields("GENERIC_NAME").Value)
' strItem = strItem & " " &
IIf(Trim((rst.Fields("BRAND_NAME").Value)) = "", "", "(" &
Trim(rst.Fields("BRAND_NAME").Value) & ")")
' strItem = strItem & " " & Trim(fDose(rst.Fields("DOSE").Value))
' strItem = strItem & " " & Trim(rst.Fields("modSig").Value)
' strItem = strItem & " " & Trim(rst.Fields("ROUTE").Value)
' strPMP = Trim(rst.Fields("Mpmp").Value)
RowItem = Trim(rst.Fields("GENERIC_NAME").Value)
RowItem = RowItem & " " & IIf(Trim((rst.Fields("BRAND_NAME").Value))
= "", "", "(" & Trim(rst.Fields("BRAND_NAME").Value) & ")")
RowItem = RowItem & " " & Trim(fDose(rst.Fields("DOSE").Value))
RowItem = RowItem & " " & Trim(rst.Fields("modSig").Value)
RowItem = RowItem & " " & Trim(rst.Fields("ROUTE").Value)
strPMP = Trim(rst.Fields("Mpmp").Value)
' strItem = RowItem
' RowItem = strItem
RowList = RowItem
RowList = RowList & RowItem
rst.MoveNext
' Me.lstMedications.AddItem strItem
' Me.lstPMP.AddItem strPMP
' rst.MoveNext
Me.lstMedications.RowSourceType = "Value List"
Me.lstMedications.RowSource = RowList
Me.lstMedications.Requery
Me.Refresh
Loop
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub
I've inherited this 2003 code that needs to work in 2000 runtime. The main
sticking point is the AddItem in a listbox. I've tried a few things but the
closest I get is it populating only one row in the box with all items. I've
included the code with remmed lines to give you a better idea of where I
was, where I am and where I need to be. What am I doing wrong? Oh, please do
reply telling me AddItem doesn't work in 2000. I know that, I just want the
same or similar effect and really don't know enough lingo to reference
correctly. Like legacy coding or some such thing.
Hope you can help.
Thanks, OMS
Private Sub Form_Load()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim frm As Form, ctl As Control
Dim varItm As Variant
Dim strSQL As String
Dim strItem As String
Dim strPMP As String
Dim strITN As String
Dim strNurSta As String
Dim strCaption As String
Dim RowItem As String
Dim RowList As String
Set frm = Forms!usr_frm_SelectMAR
Set ctl = frm!lstPatient
strSQL = "SELECT PHM_ORDERS.GENERIC_NAME, PHM_ORDERS.BRAND_NAME, " &_
"PHM_ORDERS.DOSE, PHM_ORDERS.ROUTE, Val([PMP]) AS Mpmp," & _
"IIf(IsNull([DESCRIPTION]),Trim([LATIN_DIR_ABBR]),Trim([DESCRIPTION]))
AS modSig " & _
"FROM PHM_ORDERS LEFT JOIN tblLatin ON PHM_ORDERS.LATIN_DIR_ABBR
= tblLatin.[LATIN CODE] " & _
"WHERE PHM_ORDERS.ITN = """ & m_strITN & """ " & _
"AND PHM_ORDERS.MED_IV <> ""S"" " & _
"AND PHM_ORDERS.SCH_PRN_TKH = ""SCHEDULED"" " & _
"AND PHM_ORDERS.STOPPED = ""NO"" " & _
"ORDER BY Val([PMP]) DESC ;"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)
Do Until rst.EOF
' strItem = Trim(rst.Fields("GENERIC_NAME").Value)
' strItem = strItem & " " &
IIf(Trim((rst.Fields("BRAND_NAME").Value)) = "", "", "(" &
Trim(rst.Fields("BRAND_NAME").Value) & ")")
' strItem = strItem & " " & Trim(fDose(rst.Fields("DOSE").Value))
' strItem = strItem & " " & Trim(rst.Fields("modSig").Value)
' strItem = strItem & " " & Trim(rst.Fields("ROUTE").Value)
' strPMP = Trim(rst.Fields("Mpmp").Value)
RowItem = Trim(rst.Fields("GENERIC_NAME").Value)
RowItem = RowItem & " " & IIf(Trim((rst.Fields("BRAND_NAME").Value))
= "", "", "(" & Trim(rst.Fields("BRAND_NAME").Value) & ")")
RowItem = RowItem & " " & Trim(fDose(rst.Fields("DOSE").Value))
RowItem = RowItem & " " & Trim(rst.Fields("modSig").Value)
RowItem = RowItem & " " & Trim(rst.Fields("ROUTE").Value)
strPMP = Trim(rst.Fields("Mpmp").Value)
' strItem = RowItem
' RowItem = strItem
RowList = RowItem
RowList = RowList & RowItem
rst.MoveNext
' Me.lstMedications.AddItem strItem
' Me.lstPMP.AddItem strPMP
' rst.MoveNext
Me.lstMedications.RowSourceType = "Value List"
Me.lstMedications.RowSource = RowList
Me.lstMedications.Requery
Me.Refresh
Loop
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub