VBA Coding

StefanSch

Registered User.
Local time
Today, 19:34
Joined
Jan 18, 2003
Messages
136
When I process the below code in an AfterUpdateEvent of a subform field, I get runtime error 97 (Object variable or With block variable not set).

The debug window marks the following line yellow:
OrigSelTop = SR.SelTop

FYI: I use Access97.






' Our class to hold a couple of Public vars
Private SR As clsSetRow
_____________________________________________


Private Sub Amount_AfterUpdate()

' Turn off screen redraw
Me.Painting = False

Me.Dirty = False

Dim OrigSelTop As Long
Dim RowsFromTop As Long
Dim OrigCurrentSectionTop As Long

' Must cache the current props because Requery will
' reset them
OrigSelTop = SR.SelTop
OrigCurrentSectionTop = SR.CurrentSectionTop

' Requery the Form
Me.Dirty = False
Forms![frmArticle]![subfrmDetails].Form.Requery

' Calculate how many rows, if any, the selected
' row was from the top prior to the Requery
' Check if Header is visible or not
If Me.Section(acHeader).Visible = True Then
RowsFromTop = (OrigCurrentSectionTop - Me.Section(acHeader).Height) / Me.Section(acDetail).Height
Else
RowsFromTop = OrigCurrentSectionTop / Me.Section(acDetail).Height
End If

' Setting the SelTop property forces this row to appear
' at the top of the Form. We will subtract the number of rows
' required, if any, so that the original current row remains
' at the original position prior to the Requery.
' First set the current record to the last record.
' This is required due to the method that
' that the Access GUI manages the ScrollBar.
Me.SelTop = Me.RecordsetClone.RecordCount
Me.SelTop = OrigSelTop - RowsFromTop

DoEvents

' Now setfocus back to the original row prior to the Requery
Me.RecordsetClone.AbsolutePosition = Me.CurrentRecord + RowsFromTop - 1
Me.Bookmark = Me.RecordsetClone.Bookmark

End Sub
 
I am lost on this without your help

I appreciate any help which you can provide. This issue is slowing me down so much.
 
This sort of thing is above most access developers,

but i can c where your going wrong

in order to use a class u have to create an instance of that class (Using the NEW keyword) this can be done in 2 ways.

1, when the class var is declared, ie
Private SR As NEW clsSetRow

2, or any where in code, ie
set rs = new clsSetRow



:cool:ShadeZ:cool:
 
This doesn't seem to resolve it.

I keep on having this "error messages".

Any other ideas what could be the problem?
 
Ok back to basic basics:D

The error message your getting meens that either,

OrigSelTop or SR.SelTop doesnt exist yet. (it will be SR)

to find out which is a fault run the code when the code stops hover your mouse over the variables, or print them one at a time into the intemidiate window. The one with the error is a fault.

moving on...

Your code doesnt show you setting the properties of the sr class, is this elsewhere in your code.:rolleyes: if not there is your problem (u cant set a var to something that doent exist yet)

could you paste your class module or is it jus a list of public vars




:cool:ShadeZ:cool:
 
Thanks Shadez. I appreciate your helpful comments.

On the line: "Private SR As clsSetRow", isn't as clsSetRow the property? If not, how do I set the properties?
 
Soz, been bussy this weekend

Have you solved ur problem yet or do you require more help,



:cool:ShadeZ:cool:
 
I have solved it somehow.

Thank you anyway. I appreciate your help.
 

Users who are viewing this thread

Back
Top Bottom