Results 1 to 9 of 9

Thread: Database problem

  1. #1

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Database problem

    Here's some code I'm using when using a data control in one of my apps:

    vb Code:
    1. Private Sub Data1_Validate(Action As Integer, Save As Integer)
    2. '(check1 is bound to "used", a yes/no statement
    3.  
    4. If Check1.Value = vbChecked Then
    5. Text1.Enabled = False
    6. Text2.Enabled = False
    7. Command1.Enabled = False
    8.  
    9. Else
    10.  
    11. Text1.Enabled = True
    12. Text2.Enabled = True
    13. Command1.Enabled = True
    14. End If
    15. End Sub

    However, when I come up to an entry that has "used" as true (and therefore, has the checkbox ticked), nothing happens. But then, when I go to another entry, the code runs, leaving the textboxes and button disabled.

    Any ideas on this will be thanked.
    Last edited by ajames; Jun 9th, 2007 at 10:38 AM.

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Database problem

    Validate event fires when you try to focus another control which has its causesvalidation property set to true.

  3. #3

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Re: Database problem

    So what would I need to do to get it to work how I want it to?

    EDIT: Changed the strucure of the form, so the user must press a button to choose that data.
    Last edited by ajames; Jun 9th, 2007 at 08:10 AM.

  4. #4

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Re: Database problem

    Unresolving this thread for a bit:

    How would I make the data control automatically jump to another entry in the database?

    For example, pressing a button would call entry 1, another 2 etc.

  5. #5
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Database problem

    If pressing a button, youd then call the MoveNext or MovePrev method of the recordset... there are other considerations though, such as checking .BOF or .EOF before move, and forward only recordsets can't move backwards (MovePrev, MoveFirst)

  6. #6

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Re: Database problem

    I'm not entirely sure what a recordset is (thank vb6's help for not telling me anything remotely useful ), could you tell me how to create on? If not, is there a way of getting this to work with a data object only?

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

    Re: Database problem

    If you are using DAO (and I think you are) it is:
    Code:
    Dim rs As Recordset

  8. #8

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Re: Database problem

    Does that automatically make a recordset of the data object in the current form, or do you need more code to do that?

  9. #9

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Re: Database problem

    Bumped, as it vanished of the face of the forum. The does not bind to the data control unless it is given another command - help?

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