Results 1 to 5 of 5

Thread: Problem with button....

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Problem with button....

    Dear Experts,

    I use ADO for database...and part of it I make codes likr this:

    VB Code:
    1. Private Sub cmdPrev_Click()
    2.     If Not (rst.BOF = True) Then
    3.         rst.MovePrevious 'move previous record
    4.         fillfields 'fill the controls
    5.     End If
    6.    
    7.     Application.ScreenRefresh
    8. End Sub
    9.  
    10. Private Sub cmdNext_Click()
    11.     If Not (rst.EOF = True) Then
    12.         rst.MoveNext 'move to next record
    13.         fillfields 'fill the controls
    14.     End If
    15.     Application.ScreenRefresh
    16. End Sub

    Why I have to click "Previous" or "Next" twice in order to get the next/previous record..???...how to make it only one click on this button "Previous/Next" to get the next/previous record...please...is there any missed/wrong in my codes...????

    Please help me...

    Jennifer

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Problem with button....

    Show the code for FillFields().

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Problem with button....

    Thanks for your reply...

    Here is the code:

    VB Code:
    1. Public Sub fillfields()
    2.     If Not (rst.BOF = True Or rst.EOF = True) Then 'Checks if we are at the first or last record. This is use a lot.
    3.         TextBox1.Text = rst.Fields("Item_Code") 'text1 = field2 and display that data
    4.         TextBox2.Text = rst.Fields("Description") 'as above
    5.         TextBox3.Text = rst.Fields("Qty") 'as above
    6.         TextBox4.Text = rst.Fields("Unit_Price") 'as above
    7.     Else
    8.         MsgBox "Either you are at the first record or the last record.", vbExclamation, "Cannot Move"
    9.     End If
    10. End Sub

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Problem with button....

    Looks fine.

    Can you past all your code now? I am not really sure why this would happen.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Problem with button....

    Hi,

    Please find my attached file for your review....Beside Next and Previous Button..it also the same thing with "Update Quantity" on "Fill Invoice" tab...and also for "Check Current Stock" on "Update Item" tab...I dont know why..???

    Please help me....
    Attached Files Attached Files

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