How to check conflict time-VBForums
Results 1 to 9 of 9

Thread: How to check conflict time

  1. #1

    Thread Starter
    Registered User
    Join Date
    Oct 2017
    Posts
    1

    How to check conflict time

    Name:  Untitled.jpg
Views: 129
Size:  27.4 KB
    i try this code but dont work. Please help me

    Private Sub Command1_Click()
    If conflict.State = 1 Then conflict.Close
    conflict.Open "select * from tblSchedule WHERE cmbtime1 BETWEEN !time1 AND !time2 ", dbconn, adOpenDynamic, adLockBatchOptimistic
    If conflict.RecordCount <> 0 Then
    MsgBox "Conflict", vbCritical
    Do While Not conflict.EOF
    Call sched_conflict
    Loop
    Else
    MsgBox "No Conflict"
    End If
    End Sub

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    22,884

    Re: How to check conflict time

    i try this code but dont work.
    so what does this mean?
    error? wrong result?
    what is it supposed to do?

    .recordcount may not return the correct result for a dynamic recordset
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    6,268

    Re: How to check conflict time

    Red....

    Welcome to the Forum!

    Might I suggest you use the formatting function on the Thread Menu to enclose your code in 'code tags'? Use the # symbol and then paste your code in between what appears.

    Also, get in the habit of properly indenting your code in your IDE. Makes it SO much easier to follow/decipher.

    Why the "!" in front of your two time fields? Is it included in the field name. If so, I'd refrain from using special characters in field names.


    Sammi

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    31,104

    Re: How to check conflict time

    Quote Originally Posted by westconn1 View Post
    so what does this mean?
    error? wrong result?
    what is it supposed to do?

    .recordcount may not return the correct result for a dynamic recordset
    My guess is that his fingers fell off, since there are no other details...


    Quote Originally Posted by SamOscarBrown View Post
    Red....

    Welcome to the Forum!

    Might I suggest you use the formatting function on the Thread Menu to enclose your code in 'code tags'? Use the # symbol and then paste your code in between what appears.

    Also, get in the habit of properly indenting your code in your IDE. Makes it SO much easier to follow/decipher.

    Why the "!" in front of your two time fields? Is it included in the field name. If so, I'd refrain from using special characters in field names.


    Sammi
    They're parameters... I'm willing to bet that the query was made originally in Access, when Access encounters an object name it can't resolve, it'll assume it's a parameter and will prompt the user for the values. But that's an action/product of Access. VB6 isn't going to do that. Niether is DAO/ADO. He's going to likely need to change how he's creating the recordset. Either by changing to dynamic SQL (*shivers*) or by using a Command object and then adding/setting .Parameters to the proper values and .Execute the query to get the result.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    22,884

    Re: How to check conflict time

    Why the "!" in front of your two time fields?
    i believe, they would have to be 2 of the textboxes on the form
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    16,500

    Re: How to check conflict time

    Quote Originally Posted by westconn1 View Post
    i believe, they would have to be 2 of the textboxes on the form
    The ! (bang operator) can be used to identify a field within Access: TableName!FieldName
    The bang operator tells Access that what follows is an object that belongs to the collection that precedes the bang operator.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VB and DPI Tutorial} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    6,268

    Re: How to check conflict time

    Quote Originally Posted by LaVolpe View Post
    The ! (bang operator) can be used to identify a field within Access: TableName!FieldName
    Does one have to use the table name when using the BO? Simply looked out of place in the SQl above. Much like the ! is used in recordsets (rs!fieldname), one has to use the recordset name to preface the fieldname returned. Would have thought Access would have required same...NO?

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    22,884

    Re: How to check conflict time

    as the OP has not been back, this all seems a bit irrelevant
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Posts
    17,486

    Re: How to check conflict time

    The code I can see looks pretty nightmarish, from the dynamic SQL to the use of incompatible values adOpenDynamic and adLockBatchOptimistic.

    It looks like this question has been crossposted to several sites, so maybe somebody unraveled the mumbo-jumbo and helped him sorta kinda get it working.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.