-
Oct 3rd, 2017, 04:55 AM
#1
Thread Starter
Registered User
How to check conflict time
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
-
Oct 3rd, 2017, 06:33 AM
#2
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
-
Oct 3rd, 2017, 07:01 AM
#3
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
-
Oct 3rd, 2017, 09:24 AM
#4
Re: How to check conflict time
Originally Posted by westconn1
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...
Originally Posted by SamOscarBrown
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
-
Oct 3rd, 2017, 03:23 PM
#5
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
-
Oct 3rd, 2017, 05:22 PM
#6
Re: How to check conflict time
Originally Posted by westconn1
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.
-
Oct 4th, 2017, 05:09 AM
#7
Re: How to check conflict time
Originally Posted by LaVolpe
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?
-
Oct 4th, 2017, 05:40 AM
#8
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
-
Oct 4th, 2017, 02:08 PM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|