|
-
Nov 13th, 2003, 04:45 AM
#1
Thread Starter
Junior Member
Multi-Table Access = Head Spinning Fun
I'm having a couple of problems here with my databases:
1) For some reason I can't load all the zip codes from the zip code database into my combo box anymore. It worked before, but now it just hangs.
2) The big problem I'm having is I have three tables. Table one is the employee table which contains the zip code. Table Two is the ZipCode table which contains each zip code, and it's corresponding city and state abbreviation. Table Three is the State table which has an autonumber, State Abbreviation, and State Name.
Now, when the user selects an employee from the employee combo box, I want to fill in the rest of the information automatically. How can I get it so it links the zip codes together to fill in the city (which is in a text box) and the state name (which is in a combo box)?
here's the bit of code that I have so far for this, but it isn't working.
Code:
Private Sub FormShow()
Dim objItemEmp As ListItemNumeric
Dim objItemZip As ListItemNumeric
Dim strID As String
Dim objDREmp As DataRow
Dim objDRZip As DataRow
Dim picpath, picloc As String
picpath = "images\employee\"
objItemEmp = CType(cmbEmpID.SelectedItem, ListItemNumeric)
With mobjDS.Tables("Employee").Rows
objDREmp = .Find(objItemEmp.ItemValue)
End With
'objItemZip = CType(cmbZipCode.SelectedItem, ListItemNumeric)
'With mobjDS.Tables("Zip_Code").Rows
'objDRZip = .Find(objItemZip.city)
'End With
txtFName.Text = objDREmp("emp_first").ToString()
txtLName.Text = objDREmp("emp_last").ToString()
txtAddress.Text = objDREmp("emp_address").ToString
strID = objDREmp("emp_zip").ToString
FindItem(cmbZipCode, strID)
txtEmail.Text = objDREmp("emp_email").ToString
txtPicName.Text = objDREmp("emp_pic_name").ToString
If txtPicName.Text <> "" Then
picloc = picpath & txtPicName.Text
Else
picloc = "images\na.bmp"
End If
Try
pcbEmployee.Image = Image.FromFile(picloc)
Catch filenotfound As IO.FileNotFoundException
MessageBox.Show(filenotfound.Message, "Picture Error")
End Try
strID = objDREmp("emp_zip").ToString
FindItem(cmbZipCode, strID)
'txtCity.Text = objDRZip("City").ToString
'strID = objDRZip("Zip").ToString()
'MessageBox.Show("Practice")
'FindItem(cmbZipCode, strID)
End Sub
Private Sub FindItem(ByVal cmbCombo As ComboBox, ByVal strID As String)
Dim intLoop As Integer
Dim blnFound As Boolean
Dim objItem As New ListItemNumeric()
For intLoop = 0 To cmbCombo.Items.Count - 1
objItem = CType(cmbCombo.Items(intLoop), ListItemNumeric)
If objItem.ItemID = CInt(strID) Then
cmbCombo.SelectedIndex = intLoop
blnFound = True
Exit For
End If
Next
If Not blnFound Then
cmbCombo.SelectedIndex = -1
MessageBox.Show("Not found")
End If
End Sub
Your help is appreciated. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|