Results 1 to 2 of 2
  1. #1
    DYA is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    2

    Question Tackling adPosEOF while using .Absolue Position

    Hi guys
    I have a form, which is unbound to any table or query and has unbound controls that are populated with the values from ADO recordset. This ADO recordset is an instance of a class object. On the form i have certain fields (properies of the calss) displayed in text boxes, such as ID, Name, etc. and combo box, which allows user to select Name field and then form would display the remaining details in controls for the selected record.

    Below is the simple code (establishment of connection, creation of recordset instance and etc. are executed in different subs). It runs fine except for the case when cursor reaches the EOF and assigns .AbsoluteProperty positionenum value -3 (which means EOF) and as my sub uses value of .absoluteposition to reference the ID of the record in the recordset and then to retrieve it and populate form controls it gives an error. I tried a number of ways to handle it but couldnt come up with anything workable. Please, help how to write a trap for .EOF error.
    Thanks!

    Private Sub cboGoTo_AfterUpdate()

    'if recordset isn't empty move to selected in combo record in the local disconnected recordset
    If Not rsBarriers.BOF And Not rsBarriers.EOF Then
    rsBarriers.Find " [txtGICSIndustry] = '" & Me.cboGoTo & "'"
    intCurrBarrierRecord = rsBarriers.AbsolutePosition



    'add code to populate object with new current record
    objBarriers.PopulatePropertiesFromRecordset rsBarriers

    'populate the controls on the form with the current record
    Call PopulateBarriersControls

    End If

    Exit Sub

    End Sub



  2. #2
    DYA is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    2
    False alarm, fixed it with one line of code after
    'If Not rsBarriers.BOF And Not rsBarriers.EOF Then' line

    Private Sub cboGoTo_AfterUpdate()

    'if recordset isn't empty move to selected in combo record in the local disconnected recordset
    If Not rsBarriers.BOF And Not rsBarriers.EOF Then
    rsBarriers.MoveFirst
    rsBarriers.Find " [txtGICSIndustry] = '" & Me.cboGoTo & "'"
    intCurrBarrierRecord = rsBarriers.AbsolutePosition

    'add code to populate object with new current record
    objBarriers.PopulatePropertiesFromRecordset rsBarriers

    'populate the controls on the form with the current record
    Call PopulateBarriersControls

    End If

    Exit Sub

    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Position of scroll bar
    By VictoriaAlbert in forum Access
    Replies: 2
    Last Post: 04-14-2011, 04:29 PM
  2. Set Form Position
    By Yance in forum Programming
    Replies: 3
    Last Post: 11-29-2010, 02:20 PM
  3. Show Mouse Position
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-31-2010, 04:37 AM
  4. Append Query position
    By t_dot in forum Queries
    Replies: 7
    Last Post: 08-11-2010, 11:17 AM
  5. position multiple subforms
    By Mclaren in forum Programming
    Replies: 1
    Last Post: 07-12-2010, 08:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums