Results 1 to 6 of 6

Thread: .absoluteposition = -3

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    84

    .absoluteposition = -3

    pls help me why is it my .absoluteposition is alwas = -3

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: .absoluteposition = -3

    Please give a little more description and the code you tried.

    I don't do databases that frequently, so I had to google to find that it is a ADO problem.

    Edit:
    Please don't post duplicate threads. Thanks.
    http://www.vbforums.com/showthread.p...wpost&t=452014
    Last edited by iPrank; Feb 10th, 2007 at 01:29 AM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: help pls

    give us more details. post your codes.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    84

    Re: help pls

    here's my code
    VB Code:
    1. Option Explicit
    2. Dim AY As String
    3. Dim ls As ListItem
    4.  
    5.  
    6. Private Sub cmdAdd_Click()
    7. frmAcademicAE.addstate = True
    8. frmAcademicAE.Show
    9.  
    10. End Sub
    11.  
    12. Private Sub cmdClose_Click()
    13. Unload Me
    14. End Sub
    15.  
    16. Private Sub cmdDelete_Click()
    17. On Error GoTo Err:
    18. With tbAcademicYear
    19.     '---------------------------------
    20.     'Check if there is no record
    21.     '---------------------------------
    22. '    If .RecordCount < 1 Then MsgBox "No school year in the list.Please check it!", vbExclamation, "CSRS version 1": Exit Sub
    23.     '---------------------------------
    24.     'Confirm deletion of record
    25.     '---------------------------------
    26.     Dim ans As Integer
    27.     Dim pos As Integer
    28.     ans = MsgBox("Are you sure you want to delete the selected record?", vbCritical + vbYesNo, "Confirm Record Delete")
    29.     If ans = vbYes Then
    30.         '-----------------------------
    31.         'Delete the record
    32.         '-----------------------------
    33.         pos = Val(LV1.SelectedItem)
    34.        '  tbacademicyear.Open "Select * from tbacademicyear where academicyearTitle='" & LV1.SelectedItem.Text & "'", cn, adOpenDynamic, adLockOptimistic
    35.              If .EOF = False Then
    36.                 .Delete adAffectCurrent
    37.                 '.Requery
    38.              End If
    39.        
    40.         If .RecordCount > 0 Then
    41.             .AbsolutePosition = pos
    42.             If .EOF Then .MoveFirst
    43.             '---------------------------------
    44.             'Fill listview
    45.             '---------------------------------
    46.             pos = .AbsolutePosition
    47.             load_rec
    48.             LV1.ListItems.Item(pos).EnsureVisible
    49.             LV1.ListItems.Item(pos).Selected = True
    50.             .AbsolutePosition = LV1.SelectedItem
    51.             '---------------------------------
    52.             'End-fill listview
    53.             '---------------------------------
    54.         'Else
    55.            ' LV1.ListItems.Clear
    56.         End If
    57.                 MsgBox "Record has been successfully deleted.", vbInformation, "Confirm"
    58.     End If
    59.     ans = 0
    60.     pos = 0
    61.     Me.MousePointer = vbDefault
    62. End With
    63. Exit Sub
    64. Err:
    65.     MsgBox Err.Description, vbCritical, "Academic Year"
    66.  
    67. End Sub
    68.  
    69. Private Sub cmdEdit_Click()
    70.  
    71. With tbAcademicYear
    72.  
    73. 'If .RecordCount < 1 Then MsgBox "No school year in the list.Please check it!", vbExclamation, "Titus School of Multimedia": Exit Sub
    74.  
    75. If Not LV1.SelectedItem = "" And Not tbAcademicYear.RecordCount < 1 Then .AbsolutePosition = LV1.SelectedItem
    76. frmAcademicAE.addstate = False
    77. frmAcademicAE.Show
    78. Me.Enabled = False
    79. 'End If
    80. End With
    81. End Sub
    82.  
    83.  
    84. Private Sub Form_Load()
    85. tbAcademicYear.CursorLocation = adUseClient
    86. tbAcademicYear.Open "Select * from tbacademicyear", cn, adOpenKeyset, adLockOptimistic
    87.  
    88. CallFields
    89. End Sub
    90.  
    91. Private Sub CallFields()
    92. With tbAcademicYear
    93.     LV1.ListItems.Clear
    94.     While .EOF = False
    95.         Set ls = LV1.ListItems.Add(, , .Fields(0))
    96.         .MoveNext
    97.     Wend
    98. End With
    99. End Sub
    100.  
    101. Sub load_rec()
    102. Screen.MousePointer = vbHourglass
    103.  
    104. CallFields
    105. Screen.MousePointer = vbDefault
    106. End Sub
    107.  
    108. Private Sub Form_Unload(Cancel As Integer)
    109. tbAcademicYear.Close
    110. End Sub
    111. Private Sub LV1_Click()
    112. Dim a As String
    113. a = tbAcademicYear.AbsolutePosition
    114. If Not tbAcademicYear.RecordCount < 1 Then a = LV1.SelectedItem
    115. End Sub

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: .absoluteposition = -3

    Duplicate threads merged.

    Please do not post the same question in multiple threads.

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: .absoluteposition = -3

    Hack - you must have missed another thread - we talked about this more yesterday...

    http://www.vbforums.com/showthread.p...count+movelast

    @mheiy - why are you still checking for .RecordCount > 0???

    You need to "jiggle" the recordset as TechGnome and I suggested yesterday.

    That means after immediately after you read the recordset from the database you do a MOVELAST so that the entire recordset is on the client side. Then the recordcount will not be -1 anymore.

    Fix this first before trying to understand why the rest of your logic is flawed.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width