G
Guest
I have a created two forms. The first form is the search form. The search
form uses two text boxes that can be used to search the database via either a
last name or a Party Number.
The Last Name is obviously a string. The Party Number was previously set up
as a string, but I have changed it to a Number (long type).
Since the change of the PartyNumber from a string to a number (long type),
the picklist either will open blank or will create errors.
If I enter in a Last Name (string), I get the error “2465: can’t find the
PartyNumber referenced in your expressionâ€
Any help is appreciated….
Below is the code attached to each of the forms:
frmSEARCH:
Option Compare Database
Private Sub LastName_AfterUpdate()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmDEFENDANTSmain"
stLinkCriteria = "[LastName] like '" & "*" & Me.LastName & "*'"
If DCount("*", "taDefendant", stLinkCriteria) > 0 Then
DoCmd.openFORM _
FormName:="frmPICKLIST", _
OpenArgs:=stLinkCriteria
Else
MsgBox "There is no Defendant with this LAST name in the database."
End If
End Sub
Private Sub PartyNumber_AfterUpdate()
Dim stDocName As String
Dim stLinkCriteria As Long
stDocName = "frmDEFENDANTSmain"
stLinkCriteria = [PartyNumber] = Me!PartyNumber
If DCount("*", "taDefendant", stLinkCriteria) > 0 Then
DoCmd.openFORM _
FormName:="frmPICKLIST", _
OpenArgs:=stLinkCriteria
Else
MsgBox "There is no Defendant with this PARTY NUMBER in the
database."
End If
End Sub
frmPICKLIST
Option Compare Database
Private Sub Form_Load()
With Me
.NavigationButtons = False
.RecordSelectors = False
End With
With Names
.RowSource = "SELECT [PartyNumber],[LastName],[FirstName], [MiddleName],
[Suffix] FROM taDefendant WHERE " & Me.OpenArgs & "ORDER BY LastName,
Firstname"
.ColumnCount = 5
.ColumnWidths = "1 in;1.25 in; 1.25 in; 1.25 in; .75 in"
.ColumnHeads = True
.Requery
End With
' Closes Search Form
'
DoCmd.Close acForm, "frmSEARCH"
DoCmd.Close acForm, "frmDEFENDANTSmain"
End Sub
Private Sub Names_DblClick(Cancel As Integer)
Dim F As Form
Dim R As DAO.Recordset
DoCmd.openFORM "frmDEFENDANTSmain"
Set F = Forms![frmDEFENDANTSmain]
Set R = F.RecordsetClone
R.FindFirst "[taDEFENDANT].[PartyNumber] = '" & Me!PartyNumber & "'"
F.Bookmark = R.Bookmark
DoCmd.Close acForm, Me.Name
End Sub
form uses two text boxes that can be used to search the database via either a
last name or a Party Number.
The Last Name is obviously a string. The Party Number was previously set up
as a string, but I have changed it to a Number (long type).
Since the change of the PartyNumber from a string to a number (long type),
the picklist either will open blank or will create errors.
If I enter in a Last Name (string), I get the error “2465: can’t find the
PartyNumber referenced in your expressionâ€
Any help is appreciated….
Below is the code attached to each of the forms:
frmSEARCH:
Option Compare Database
Private Sub LastName_AfterUpdate()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmDEFENDANTSmain"
stLinkCriteria = "[LastName] like '" & "*" & Me.LastName & "*'"
If DCount("*", "taDefendant", stLinkCriteria) > 0 Then
DoCmd.openFORM _
FormName:="frmPICKLIST", _
OpenArgs:=stLinkCriteria
Else
MsgBox "There is no Defendant with this LAST name in the database."
End If
End Sub
Private Sub PartyNumber_AfterUpdate()
Dim stDocName As String
Dim stLinkCriteria As Long
stDocName = "frmDEFENDANTSmain"
stLinkCriteria = [PartyNumber] = Me!PartyNumber
If DCount("*", "taDefendant", stLinkCriteria) > 0 Then
DoCmd.openFORM _
FormName:="frmPICKLIST", _
OpenArgs:=stLinkCriteria
Else
MsgBox "There is no Defendant with this PARTY NUMBER in the
database."
End If
End Sub
frmPICKLIST
Option Compare Database
Private Sub Form_Load()
With Me
.NavigationButtons = False
.RecordSelectors = False
End With
With Names
.RowSource = "SELECT [PartyNumber],[LastName],[FirstName], [MiddleName],
[Suffix] FROM taDefendant WHERE " & Me.OpenArgs & "ORDER BY LastName,
Firstname"
.ColumnCount = 5
.ColumnWidths = "1 in;1.25 in; 1.25 in; 1.25 in; .75 in"
.ColumnHeads = True
.Requery
End With
' Closes Search Form
'
DoCmd.Close acForm, "frmSEARCH"
DoCmd.Close acForm, "frmDEFENDANTSmain"
End Sub
Private Sub Names_DblClick(Cancel As Integer)
Dim F As Form
Dim R As DAO.Recordset
DoCmd.openFORM "frmDEFENDANTSmain"
Set F = Forms![frmDEFENDANTSmain]
Set R = F.RecordsetClone
R.FindFirst "[taDEFENDANT].[PartyNumber] = '" & Me!PartyNumber & "'"
F.Bookmark = R.Bookmark
DoCmd.Close acForm, Me.Name
End Sub