I'm having problems figuring out how to output userform data in excel to an excel table that is formatted as a table.
Is there a way to "add existing fields" to the userform like you can do in Access.
It is just a simple contact database (company name, contact, address...)
Here is the code I am trying, but it never reaches the table as I don't have the table defined... not sure how to specify the table (called Table_Customer_Contact_DB)
Thanks for any suggestions....
Printmark
Is there a way to "add existing fields" to the userform like you can do in Access.
It is just a simple contact database (company name, contact, address...)
Here is the code I am trying, but it never reaches the table as I don't have the table defined... not sure how to specify the table (called Table_Customer_Contact_DB)
Code:
Private Sub btnSaveAndReturn_Click()
Dim i, j As Integer
Dim varCustomer As Variant
Dim varContact As Variant
Dim varStreet1 As Variant
Dim varStreet2 As Variant
Dim varCity As Variant
Dim varEmail As Variant
Me.lblEmail.ForeColor = 0
Me.lblStreet2.ForeColor = 0
Me.lblCustomer.ForeColor = 0
Me.lblContact.ForeColor = 0
Me.lblStreet1.ForeColor = 0
Me.lblCity.ForeColor = 0
varNo = Array("\", "/", ":", "*", "?", """", "<", ">", "|", "'")
If IsNull(Me.txbCustomer) = False Then
varCustomer = Me.txbCustomer
For i = 0 To UBound(varNo)
j = InStr(1, varCustomer, varNo(i))
If j > 0 Then
MsgBox "Cannot use character:" & Chr(13) & Chr(10) & Chr(13) _
& Chr(10) & varNo(i), vbCritical, " Illegal Character"
Me.lblCustomer.ForeColor = 255
Exit Sub
Exit For
End If
Next
End If
If IsNull(Me.txbContact) = False Then
varContact = Me.txbContact
For i = 0 To UBound(varNo)
j = InStr(1, varContact, varNo(i))
If j > 0 Then
MsgBox "Cannot use character:" & Chr(13) & Chr(10) & Chr(13) _
& Chr(10) & varNo(i), vbCritical, " Illegal Character"
Me.lblContact.ForeColor = 255
Exit Sub
Exit For
End If
Next
End If
If IsNull(Me.Street1) = False Then
varStreet1 = Me.Street1
For i = 0 To UBound(varNo)
j = InStr(1, varStreet1, varNo(i))
If j > 0 Then
MsgBox "Cannot use character:" & Chr(13) & Chr(10) & Chr(13) _
& Chr(10) & varNo(i), vbCritical, " Illegal Character"
Me.lblStreet1.ForeColor = 255
Exit Sub
Exit For
End If
Next
End If
If IsNull(Me.txbStreet2) = False Then
varStreet2 = Me.txbStreet2
For i = 0 To UBound(varNo)
j = InStr(1, varStreet2, varNo(i))
If j > 0 Then
MsgBox "Cannot use character:" & Chr(13) & Chr(10) & Chr(13) _
& Chr(10) & varNo(i), vbCritical, " Illegal Character"
Me.lblStreet2.ForeColor = 255
Exit Sub
Exit For
End If
Next
End If
If IsNull(Me.txbCity) = False Then
varCity = Me.txbCity
For i = 0 To UBound(varNo)
j = InStr(1, varCity, varNo(i))
If j > 0 Then
MsgBox "Cannot use character:" & Chr(13) & Chr(10) & Chr(13) _
& Chr(10) & varNo(i), vbCritical, " Illegal Character"
Me.lblCity.ForeColor = 255
Exit Sub
Exit For
End If
Next
End If
If IsNull(Me.txbEmail) = False Then
varEmail = Me.txbEmail
For i = 0 To UBound(varNo)
j = InStr(1, varEmail, varNo(i))
If j > 0 Then
MsgBox "Cannot use character:" & Chr(13) & Chr(10) & Chr(13) _
& Chr(10) & varNo(i), vbCritical, " Illegal Character"
Me.lblEmail.ForeColor = 255
Exit Sub
Exit For
End If
Next
End If
Unload Me
End Sub
Thanks for any suggestions....
Printmark