citizen_cow
04-15-2004, 03:04 PM
Hi all. Love teh new layout. Very FRESH.
I created this program with the help of everyone here and now have a need to create a 2nd database for the same program.
It conisists of tabs and 2 combo boxes.
first tab is a combo where you enter a number, that tab and the next tab populate with the corresponding info.
Im trying to add a third tab with the same function, different info. Im having trouble adding in a second access db into the same code. Any direction.
The code as it is now is attached.
As it is now. The "TECH" is the cbo
http://spinningbus.com/vb/view1.jpg
http://spinningbus.com/vb/view2.jpg
the one I want to add to pull from a seperate database
"INITIALS" is the cbo...
http://spinningbus.com/vb/view3.jpg
Dim MouseX, MouseY
Dim db As Database
Dim rs As Recordset
Dim strslq As String
Option Explicit
Private Sub Populate()
Dim strsql As String
strsql = "select Name,Department,Sup_Nextel,Nextel,Cell,Supervisor,Supervisor_Cell from Sheet1 where Tech=" & cboTech.Text
' Get the recorset
Set rs = db.OpenRecordset(strsql)
' Put the info in the text fields
rs.MoveFirst ' Get first item
txtName.Text = rs!Name
txtDepartment.Text = rs!Department
txtSup_Nextel.Text = rs!Sup_Nextel
txtCell.Text = rs!Cell
txtNextel.Text = rs!Nextel
txtSupervisor.Text = rs!Supervisor
txtSUpervisor_cell.Text = rs!Supervisor_Cell
rs.Close
End Sub
Private Sub cboTech_click()
Populate
End Sub
Private Sub cboTech_()
Const MaxLength As Integer = 4 'the maximum
If Len(cboTech.Text) > MaxLength Then
cboTech.Text = Mid(cboTech.Text, 1, MaxLength)
End If
End Sub
Private Sub cmnd_close_Click()
Unload Me
End Sub
Private Sub cmndMin_Click()
WindowState = vbMinimized
End Sub
Private Sub Form_Load()
Me.Move (Screen.Width - Me.ScaleWidth) / 2, (Screen.Height - Me.ScaleHeight) / 2
Set db = DBEngine.OpenDatabase("\\timon\public\Aspect\Reports\Dispatch\2003\db\db1.mdb")
' Get the recorset
Set rs = db.OpenRecordset("select Tech from Sheet1")
' Grab all the items and put them in the combo box
rs.MoveFirst ' Get first item
While (Not rs.EOF)
If Not IsNull(rs!Tech) Then
cboTech.AddItem rs!Tech
End If
rs.MoveNext
Wend
rs.Close
cboTech.Text = cboTech.List(0)
Populate
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
MouseX = X
MouseY = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
DoEvents
If Button = vbLeftButton Then
Left = Left - (MouseX - X)
Top = Top - (MouseY - Y)
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
db.Close
End Sub
I created this program with the help of everyone here and now have a need to create a 2nd database for the same program.
It conisists of tabs and 2 combo boxes.
first tab is a combo where you enter a number, that tab and the next tab populate with the corresponding info.
Im trying to add a third tab with the same function, different info. Im having trouble adding in a second access db into the same code. Any direction.
The code as it is now is attached.
As it is now. The "TECH" is the cbo
http://spinningbus.com/vb/view1.jpg
http://spinningbus.com/vb/view2.jpg
the one I want to add to pull from a seperate database
"INITIALS" is the cbo...
http://spinningbus.com/vb/view3.jpg
Dim MouseX, MouseY
Dim db As Database
Dim rs As Recordset
Dim strslq As String
Option Explicit
Private Sub Populate()
Dim strsql As String
strsql = "select Name,Department,Sup_Nextel,Nextel,Cell,Supervisor,Supervisor_Cell from Sheet1 where Tech=" & cboTech.Text
' Get the recorset
Set rs = db.OpenRecordset(strsql)
' Put the info in the text fields
rs.MoveFirst ' Get first item
txtName.Text = rs!Name
txtDepartment.Text = rs!Department
txtSup_Nextel.Text = rs!Sup_Nextel
txtCell.Text = rs!Cell
txtNextel.Text = rs!Nextel
txtSupervisor.Text = rs!Supervisor
txtSUpervisor_cell.Text = rs!Supervisor_Cell
rs.Close
End Sub
Private Sub cboTech_click()
Populate
End Sub
Private Sub cboTech_()
Const MaxLength As Integer = 4 'the maximum
If Len(cboTech.Text) > MaxLength Then
cboTech.Text = Mid(cboTech.Text, 1, MaxLength)
End If
End Sub
Private Sub cmnd_close_Click()
Unload Me
End Sub
Private Sub cmndMin_Click()
WindowState = vbMinimized
End Sub
Private Sub Form_Load()
Me.Move (Screen.Width - Me.ScaleWidth) / 2, (Screen.Height - Me.ScaleHeight) / 2
Set db = DBEngine.OpenDatabase("\\timon\public\Aspect\Reports\Dispatch\2003\db\db1.mdb")
' Get the recorset
Set rs = db.OpenRecordset("select Tech from Sheet1")
' Grab all the items and put them in the combo box
rs.MoveFirst ' Get first item
While (Not rs.EOF)
If Not IsNull(rs!Tech) Then
cboTech.AddItem rs!Tech
End If
rs.MoveNext
Wend
rs.Close
cboTech.Text = cboTech.List(0)
Populate
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
MouseX = X
MouseY = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
DoEvents
If Button = vbLeftButton Then
Left = Left - (MouseX - X)
Top = Top - (MouseY - Y)
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
db.Close
End Sub