Function doesnt always work?

P

Patrick Graham

I have function:

Sub PullRec(subfrm As Form, lbxMatchClmn As Variant,
varMatch As String)
Dim rs As Object
Set rs = subfrm.Recordset.Clone
If IsNumeric(lbxMatchClmn) Then
rs.FindFirst "[" & varMatch & "] = " & lbxMatchClmn
Else
rs.FindFirst "[" & varMatch & "] = '" & lbxMatchClmn & "'"
End If
If Not rs.EOF Then subfrm.Bookmark = rs.Bookmark
rs.Close
End Sub

Which I use to pull records for a subform using a List
Box selection which exists on the main form.

The function works fine at home but not at the office
(both use XP Access) and I need to find out why.

Work gives me this error:

Compile error: Object library feature not supported.



The line of code that causes this is the call to function:

Call PullRec(Me![subAccount].Form,
Me.lbxClientAccountLkUp.Column(1), "AccountNumber")

It highlights the .Form part when the error pops up.

If I replace the function call with:

Dim rst As Object
Set rst = Me![subAccount].Form.Recordset.Clone
rst.FindFirst "[AccountNumber] = '" &
Me.lbxClientAccountLkUp.Column(1) & "'"
If Not rst.EOF Then Me![subAccount].Form.Bookmark =
rst.Bookmark
rst.Close


it works fine but I'ld rather use my function. The odd
thing is the function is used a couple times to populate
different subforms before this one. Any thoughts?
 
P

Patrick Graham

Odd now suddenly the other calls to the function PullRec
do not work either. This is after having successfully
used them at work several times. Maybe its a table data
issue.
 
P

Patrick Graham

Don't see how its the tables though!!! Why would the
function suddenly stop working, even if I close access
and reload it still doesnt work.
-----Original Message-----
Odd now suddenly the other calls to the function PullRec
do not work either. This is after having successfully
used them at work several times. Maybe its a table data
issue.
-----Original Message-----
I have function:

Sub PullRec(subfrm As Form, lbxMatchClmn As Variant,
varMatch As String)
Dim rs As Object
Set rs = subfrm.Recordset.Clone
If IsNumeric(lbxMatchClmn) Then
rs.FindFirst "[" & varMatch & "] = " & lbxMatchClmn
Else
rs.FindFirst "[" & varMatch & "] = '" & lbxMatchClmn & "'"
End If
If Not rs.EOF Then subfrm.Bookmark = rs.Bookmark
rs.Close
End Sub

Which I use to pull records for a subform using a List
Box selection which exists on the main form.

The function works fine at home but not at the office
(both use XP Access) and I need to find out why.

Work gives me this error:

Compile error: Object library feature not supported.



The line of code that causes this is the call to function:

Call PullRec(Me![subAccount].Form,
Me.lbxClientAccountLkUp.Column(1), "AccountNumber")

It highlights the .Form part when the error pops up.

If I replace the function call with:

Dim rst As Object
Set rst = Me![subAccount].Form.Recordset.Clone
rst.FindFirst "[AccountNumber] = '" &
Me.lbxClientAccountLkUp.Column(1) & "'"
If Not rst.EOF Then Me![subAccount].Form.Bookmark =
rst.Bookmark
rst.Close


it works fine but I'ld rather use my function. The odd
thing is the function is used a couple times to populate
different subforms before this one. Any thoughts?
.
.
 
P

Patrick Graham

Hmmmm Corrections
The file format is Access 2000
Work Access is Access 2002
and my Home Access is what ever XP Office comes with.
-----Original Message-----
Don't see how its the tables though!!! Why would the
function suddenly stop working, even if I close access
and reload it still doesnt work.
-----Original Message-----
Odd now suddenly the other calls to the function PullRec
do not work either. This is after having successfully
used them at work several times. Maybe its a table data
issue.
-----Original Message-----
I have function:

Sub PullRec(subfrm As Form, lbxMatchClmn As Variant,
varMatch As String)
Dim rs As Object
Set rs = subfrm.Recordset.Clone
If IsNumeric(lbxMatchClmn) Then
rs.FindFirst "[" & varMatch & "] = " & lbxMatchClmn
Else
rs.FindFirst "[" & varMatch & "] = '" & lbxMatchClmn & "'"
End If
If Not rs.EOF Then subfrm.Bookmark = rs.Bookmark
rs.Close
End Sub

Which I use to pull records for a subform using a List
Box selection which exists on the main form.

The function works fine at home but not at the office
(both use XP Access) and I need to find out why.

Work gives me this error:

Compile error: Object library feature not supported.



The line of code that causes this is the call to function:

Call PullRec(Me![subAccount].Form,
Me.lbxClientAccountLkUp.Column(1), "AccountNumber")

It highlights the .Form part when the error pops up.

If I replace the function call with:

Dim rst As Object
Set rst = Me![subAccount].Form.Recordset.Clone
rst.FindFirst "[AccountNumber] = '" &
Me.lbxClientAccountLkUp.Column(1) & "'"
If Not rst.EOF Then Me![subAccount].Form.Bookmark =
rst.Bookmark
rst.Close


it works fine but I'ld rather use my function. The odd
thing is the function is used a couple times to populate
different subforms before this one. Any thoughts?
.
.
.
 
D

Dirk Goldgar

Patrick Graham said:
I have function:

Sub PullRec(subfrm As Form, lbxMatchClmn As Variant,
varMatch As String)
Dim rs As Object
Set rs = subfrm.Recordset.Clone
If IsNumeric(lbxMatchClmn) Then
rs.FindFirst "[" & varMatch & "] = " & lbxMatchClmn
Else
rs.FindFirst "[" & varMatch & "] = '" & lbxMatchClmn & "'"
End If
If Not rs.EOF Then subfrm.Bookmark = rs.Bookmark
rs.Close
End Sub

Which I use to pull records for a subform using a List
Box selection which exists on the main form.

The function works fine at home but not at the office
(both use XP Access) and I need to find out why.

Work gives me this error:

Compile error: Object library feature not supported.



The line of code that causes this is the call to function:

Call PullRec(Me![subAccount].Form,
Me.lbxClientAccountLkUp.Column(1), "AccountNumber")

It highlights the .Form part when the error pops up.

If I replace the function call with:

Dim rst As Object
Set rst = Me![subAccount].Form.Recordset.Clone
rst.FindFirst "[AccountNumber] = '" &
Me.lbxClientAccountLkUp.Column(1) & "'"
If Not rst.EOF Then Me![subAccount].Form.Bookmark =
rst.Bookmark
rst.Close


it works fine but I'ld rather use my function. The odd
thing is the function is used a couple times to populate
different subforms before this one. Any thoughts?

I don't see yet why your function works at home but not at the office,
and I can't explain the error message. However, most often when Access
applications work in one location and not in another, it's because of a
broken reference. Have you opened the References dialog in the office
copy to see if there are any references marked as MISSING?

I must point out, though, that there is an error in your function
regardless of whether it appears to be working or not. You call
rs.FindFirst, and then check for rs.EOF, apparently to check if a match
was found. However, rs.EOF will *not* be set if no match is found.
Instead rs.NoMatch is set. The current record pointer is then unknown.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top