troubleshooting Question

Access alphanumeric value

Avatar of shieldsco
shieldscoFlag for United States of America asked on
Microsoft Access
7 Comments1 Solution321 ViewsLast Modified:
The following code works when the user enters an alpha value followed by a numeric value (LL-15-KH) however when the user enters a numeric value first followed by an alpha value (15-HH-YY-2010) the code does not work. I get a type mismatch. I'm think the problems lies in the following statement; tdf.Fields(strFieldName).DefaultValue = " " & Text & " "
Any thoughts

Public Sub ChangeTableFieldDefaultValueText(strTableName As String, strFieldName As String, Text As String, strFormName As String)
On Error GoTo Err_ChangeTableFieldDefaultValue

    Dim db As DAO.Database
    Dim tdf As DAO.TableDef
    Set db = CurrentDb()
    Set tdf = db.TableDefs(strTableName)
    tdf.Fields(strFieldName).DefaultValue = " " & Text & " "
        're-open calling form if name is passed
    If strFormName <> "" Then
        DoCmd.OpenForm strFormName, acNormal
    End If

    Set tdf = Nothing
    Set db = Nothing
    Exit Sub

    MsgBox Err.Number & " (" & Err.Description & ") in procedure ChangeTableFieldDefaultValue of Module DefaultsText"
    Resume Exit_ChangeTableFieldDefaultValue

End Sub
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros