knowledge76
Registered User.
- Local time
- Today, 23:46
- Joined
- Jan 20, 2005
- Messages
- 165
PHP:
Option Compare Database
Private Sub Combo3_AfterUpdate()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim vl As String
Dim strsql As String
Dim totalengines As Integer
Dim usedengines As Integer
Dim notusedengines As Integer
Dim noinfos As Integer
List6.RowSource = ""
vl = Combo3.Value
Text13.Value = vbNullString
Text15.Value = vbNullString
Text17.Value = vbNullString
usedengines = 0
notusedengines = 0
noinfos = 0
strsql = "SELECT TBL_VP_" & Forms!Form1!Combo3.Value & ".VEHICLE_LINE_WERS AS VLWERS" '& vbNewLine
strsql = strsql & ", TBL_VP_" & Forms!Form1!Combo3.Value & ".ENGINE AS ENGINE" '& vbNewLine
strsql = strsql & ", TBL_AWS_ENGINE.Engine_Description as ENG_DESC" '& vbNewLine
strsql = strsql & ", TBL_AWS_ENGINE.Used as USED" '& vbNewLine
strsql = strsql & " FROM TBL_VP_" & Forms!Form1!Combo3.Value & vbNewLine
strsql = strsql & " LEFT JOIN TBL_AWS_ENGINE " '& vbNewLine
strsql = strsql & " ON TBL_VP_" & Forms!Form1!Combo3.Value & ".ENGINE = TBL_AWS_ENGINE.Engine_Code" & vbNewLine
strsql = strsql & " GROUP BY TBL_VP_" & Forms!Form1!Combo3.Value & ".VEHICLE_LINE_WERS" '& vbNewLine
strsql = strsql & ", TBL_VP_" & Forms!Form1!Combo3.Value & ".ENGINE"
strsql = strsql & ", TBL_AWS_ENGINE.Engine_Description" '& vbNewLine
strsql = strsql & ", TBL_AWS_ENGINE.Used;"
Debug.Print strsql
Set db = CurrentDb
Set rs = db.OpenRecordset(strsql, dbOpenDynaset)
rs.MoveFirst
rs.MoveLast
totalrecords = rs.RecordCount
rs.MoveFirst
[Forms!Form1!List6.AddItem Item:="VLWERS" & " Engine" & " Description " & " Used"
Forms!Form1!List6.AddItem Item:=".................................................................................."
'Debug.Print ".................."
'Debug.Print ".................."
'Debug.Print "VLWERS" & " Engine" & " Description" & " Used"
'Debug.Print "....................................................................................."
Do While rs.EOF = False
Debug.Print rs!VLWERS & " " & rs!Engine & " " & rs!ENG_DESC & " " & rs!used
If rs!used = "Y" Then
usedengines = usedengines + 1
ElseIf rs!used = "N" Then
notusedengines = notusedengines + 1
Else
noinfos = noinfos + 1
End If
Debug.Print "VLWERS" & " Engine" & " Description " & " Used"
Forms!Form1!List6.AddItem Item:=rs!VLWERS & " " & rs!Engine & " " & rs!ENG_DESC & " " & rs!used
rs.MoveNext
Loop
Label8.Caption = "Total no. of Engines in " & vl
Label9.Caption = "Total no. of used Engines in"
Label12.Caption = "Total no. of not used Engines"
Label19.Caption = "Used / not Used with no Information"
Text13.Value = totalrecords
Text15.Value = usedengines
Text17.Value = notusedengines
Text20.Value = noinfos
Set rs = Nothing
Set db = Nothing
End Sub
with the above code I am putting the values of recordset in one column of listbox. How can put each value of recordset in different column.
Thanks for your feedback...