Private Sub Form_Open(Cancel As Integer)
' Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT TOP 100 PERCENT dbo.VehicleClass.vc_Code, dbo.Vehicle.vh_VehicleNumber, dbo.Vehicle.vh_CheckLetter, dbo.Vehicle.vh_IsActive, " & vbCrLf & _
"dbo.Vehicle.vh_cu_id_TrainOperator, dbo.Vehicle.vh_cu_id_VehicleUser, dbo.Vehicle.vh_cu_id_VehicleOwner, " & vbCrLf & _
"dbo.Vehicle.vh_cu_id_VehicleMaintainer , dbo.Vehicle.vh_TareMass, dbo.Vehicle.vh_Length, dbo.Vehicle.vh_Comments " & vbCrLf & _
"FROM dbo.Vehicle INNER JOIN " & vbCrLf & _
"dbo.VehicleClass ON dbo.Vehicle.vh_vc_id = dbo.VehicleClass.id" & vbCrLf & _
"WHERE (dbo.VehicleClass.vc_Code = 'B') " & vbCrLf & _
"ORDER BY dbo.VehicleClass.vc_Code, dbo.Vehicle.vh_VehicleNumber"
'Use Microsoft Access's OLEDB connection to the Jet database
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset
With rs
.Source = strSQL
.ActiveConnection = cn
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open
End With
Set Me.Recordset = rs
End Sub
Private Sub cmdAll_Click()
Dim rs As ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT TOP 100 PERCENT dbo.VehicleClass.vc_Code, dbo.Vehicle.vh_VehicleNumber, dbo.Vehicle.vh_CheckLetter, dbo.Vehicle.vh_IsActive, " & vbCrLf & _
"dbo.Vehicle.vh_cu_id_TrainOperator, dbo.Vehicle.vh_cu_id_VehicleUser, dbo.Vehicle.vh_cu_id_VehicleOwner, " & vbCrLf & _
"dbo.Vehicle.vh_cu_id_VehicleMaintainer , dbo.Vehicle.vh_TareMass, dbo.Vehicle.vh_Length, dbo.Vehicle.vh_Comments " & vbCrLf & _
"FROM dbo.Vehicle INNER JOIN " & vbCrLf & _
"dbo.VehicleClass ON dbo.Vehicle.vh_vc_id = dbo.VehicleClass.id" & vbCrLf & _
"WHERE (dbo.VehicleClass.vc_Code = '" & txtShowClass & "') " & vbCrLf & _
"ORDER BY dbo.VehicleClass.vc_Code, dbo.Vehicle.vh_VehicleNumber"
'Use Microsoft Access's OLEDB connection to the Jet database
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset
With rs
.Source = strSQL
.ActiveConnection = cn
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open
End With
Set Me.Recordset = rs
End Sub
|