sphere_monk
Registered User.
- Local time
- Today, 10:02
- Joined
- Nov 18, 2002
- Messages
- 62
Hi Everyone.
I'm having a problem with one form recognizing a public function and another form in the same database kicking out with an error when I try to call the same function. I'm using Access 2002. The code is as follows:
When VB hits "Call DisplayAddress" portion of code in the second form it returns an error "Compile Error - Invalid use of property" and if I right-click and try to select "Definition" to see the Public Function DisplayAddress it returns the message "Cannot jump to DisplayAddress because it is in the library 'Z:\Design\WODesign\WODesign.mdb' which is not currently referenced"
'Z:\Design\WODesign\WODesign.mdb' is the database I am working in. DisplayAddress is a Public Function contained in a Module within the same database.
Here is DisplayAddress:
Does anyone know what would cause the db to behave this way?
I'm having a problem with one form recognizing a public function and another form in the same database kicking out with an error when I try to call the same function. I'm using Access 2002. The code is as follows:
Code:
Private Sub cmdFind_Click()
On Error GoTo Err_cmdFind_Click
Dim rst As New ADODB.Recordset
Dim cnn As ADODB.Connection
Dim ReturnedAddress As String
Dim cmd As New ADODB.Command
Dim StrSql As String
Set cnn = CurrentProject.Connection
DoCmd.SetWarnings False
If Me!cboNumYears < 0 Or Me!cboNumYears > 16 Then
MsgBox "Please enter an inspection age threshold"
GoTo Exit_cmdFind_Click
End If
If Me!chkExcludeClassI = False And Me!chkPrintClassIOnly = False Then
DoCmd.OpenQuery "qryBFAddInspectedDevicesToScheduleTemp"
Else
End If
If Me!chkExcludeClassI = True And Me!chkPrintClassIOnly = False Then
DoCmd.OpenQuery ""
Else
End If
If Me!chkExcludeClassI = False And Me!chkPrintClassIOnly = True Then
DoCmd.OpenQuery ""
Else
End If
rst.Open "SELECT * FROM tblBFScheduleTempInspections", cnn
Do Until rst.EOF
Call DisplayAddress(rst!MailedToName1, rst!MailedToName2, _
rst!MailedToAddress1, rst!MailedToAddress2, rst!MailedToCity, _
rst!MailedToState, rst!MailedToZip, ReturnedAddress)
StrSql = "Update tblBFScheduleTemp Set DisplayAddress = '" & ReturnedAddress & "' Where BFID = " & rst!BFID & " and RecordType = '" & rst!RecordType & "'"
cmd.ActiveConnection = cnn
cmd.CommandText = StrSql
cmd.Execute
rst.MoveNext
Loop
rst.Close
Me.Requery
Exit_cmdFind_Click:
DoCmd.SetWarnings True
Exit Sub
Err_cmdFind_Click:
MsgBox Err.Description
Resume Exit_cmdFind_Click
End Sub
When VB hits "Call DisplayAddress" portion of code in the second form it returns an error "Compile Error - Invalid use of property" and if I right-click and try to select "Definition" to see the Public Function DisplayAddress it returns the message "Cannot jump to DisplayAddress because it is in the library 'Z:\Design\WODesign\WODesign.mdb' which is not currently referenced"
'Z:\Design\WODesign\WODesign.mdb' is the database I am working in. DisplayAddress is a Public Function contained in a Module within the same database.
Here is DisplayAddress:
Code:
Public Function DisplayAddress(Name1 As String, Name2 As String, _
Address1 As String, Address2 As String, City As String, State As String, _
Zip As String, ReturnedAddress)
Dim Line1 As String
Dim Line2 As String
Dim Line3 As String
Dim Line4 As String
Dim Line5 As String
If Trim(Name2) = "" Or IsNull(Name2) Then
Line1 = ""
Line2 = Trim(Name1) & vbCrLf
Else
Line1 = Trim(Name1) & vbCrLf
Line2 = Trim(Name2) & vbCrLf
End If
If Trim(Address1) = "" Or IsNull(Address1) Then
Line3 = Trim(Address2) & vbCrLf
Else
Line3 = Trim(Address1) & vbCrLf
End If
If Trim(Address2) = "" Or IsNull(Address2) Then
Line4 = Trim(City) & ", " & Trim(State) & " " & Trim(Zip)
Else
If Trim(Address1) = "" Or IsNull(Address1) Then
Line4 = Trim(City) & ", " & Trim(State) & " " & Trim(Zip)
Else
Line4 = Trim(Address2) & vbCrLf
End If
End If
If Trim(Address2) = "" Or IsNull(Address2) Then
Line5 = ""
Else
If Trim(Address1) = "" Or IsNull(Address1) Then
Line5 = ""
Else
Line5 = Trim(City) & ", " & Trim(State) & " " & Trim(Zip)
End If
End If
ReturnedAddress = Line1 & Line2 & Line3 & Line4 & Line5
End Function