| | |
creating queries IN ACCESS using variables IN VB
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Aug 2007
Posts: 32
Reputation:
Solved Threads: 0
i had :
but i get an error that says 'object variable or with block variable not set'
and the one that gets highlighted when i debug was line*
that's why i thought the error might be before the line * which was the query;(
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
With Adodc2 .RecordSource = "SELECT time_id FROM TF WHERE fac_id = '" & fac_type & "' AND reserv_date = '" & booking_date & "'" .Recordset.Requery* .Refresh
but i get an error that says 'object variable or with block variable not set'
and the one that gets highlighted when i debug was line*
that's why i thought the error might be before the line * which was the query;(
•
•
Join Date: Jul 2007
Posts: 192
Reputation:
Solved Threads: 16
I think there are a few problems with your code. Start with this, to compare dates you should use format$
then at all the following lines change the
else
if
to elseif and then have only one endif at the end
and change all the .recordset.fields(" ") to just .recordset(" ")
If .Recordset.Fields("time_id").Value = 8 Then
Option1.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 9 Then
Option2.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 10 Then
Option3.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 11 Then
Option4.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 12 Then
Option5.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 13 Then
Option6.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 14 Then
Option7.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 15 Then
Option8.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 16 Then
Option9.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 17 Then
Option10.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 18 Then
Option11.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 19 Then
Option12.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 20 Then
Option13.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 21 Then
Option14.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 22 Then
Option15.Enabled = False
Else
Option16.Enabled = False
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
what I still don't understand is what do you need
.recordset.requery
for???????
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
"SELECT time_id FROM TF WHERE fac_id = " & fac_type & " AND reserv_date = " & Format$(booking_date, "\#m\/d\/yyyy\#")
then at all the following lines change the
else
if
to elseif and then have only one endif at the end
and change all the .recordset.fields(" ") to just .recordset(" ")
If .Recordset.Fields("time_id").Value = 8 Then
Option1.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 9 Then
Option2.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 10 Then
Option3.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 11 Then
Option4.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 12 Then
Option5.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 13 Then
Option6.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 14 Then
Option7.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 15 Then
Option8.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 16 Then
Option9.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 17 Then
Option10.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 18 Then
Option11.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 19 Then
Option12.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 20 Then
Option13.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 21 Then
Option14.Enabled = False
Else
If .Recordset.Fields("time_id").Value = 22 Then
Option15.Enabled = False
Else
Option16.Enabled = False
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
what I still don't understand is what do you need
.recordset.requery
for???????
•
•
Join Date: Aug 2007
Posts: 32
Reputation:
Solved Threads: 0
an addition:
i tried making queries with only one criteria which was
there is a result in return.it works fine.
but when i try making queries with 2 criterias
or using only booking_date as the criteria,it returns no result.i tried checking the datatype of booking_date from access table and variable i've declared in vb.
both are of type date.
i can't seem to find where it went wrong but for sure it has something to do with dates.
anyone who care to help,thanx x10000 in advance..
i tried making queries with only one criteria which was
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
with Adodc2 .RecordSource = "SELECT time_id FROM TF WHERE fac_id = " & fac_type & "" .Refresh end with
but when i try making queries with 2 criterias
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
With Adodc2 .RecordSource = "SELECT time_id FROM TF WHERE fac_id = '" & fac_type & "' AND reserv_date = " & booking_date & "" .Recordset.Requery .Refresh
or using only booking_date as the criteria,it returns no result.i tried checking the datatype of booking_date from access table and variable i've declared in vb.
both are of type date.
i can't seem to find where it went wrong but for sure it has something to do with dates.
anyone who care to help,thanx x10000 in advance..
•
•
Join Date: Jul 2007
Posts: 192
Reputation:
Solved Threads: 16
why don't you try the select statement I wrote before, you have to use format$ in your select statement to compare dates
I tried it in your program you sent and it works, here it is again
"SELECT time_id FROM TF WHERE fac_id = " & fac_type & " AND reserv_date = " & Format$(booking_date, "\#m\/d\/yyyy\#")
I tried it in your program you sent and it works, here it is again
"SELECT time_id FROM TF WHERE fac_id = " & fac_type & " AND reserv_date = " & Format$(booking_date, "\#m\/d\/yyyy\#")
Last edited by plusplus; Oct 8th, 2007 at 3:43 am.
•
•
Join Date: Aug 2007
Posts: 32
Reputation:
Solved Threads: 0
i got a sample program from the net that uses requery and it works fine in my login form.that's why i thought it is crucial when making queries(not knowing the real flow of it).i've altered my codes as told by you and everything went smoothly.thank you very much plusplus
n also to all who had helped,thank you
n also to all who had helped,thank you
![]() |
Similar Threads
- How do I make my Access database work with MS SQL Server? (MS Access and FileMaker Pro)
- Creating an .exe using Access (MS Access and FileMaker Pro)
- Using exisiting queries within MS Access (ASP.NET)
- How do I access variables in my queue? (C++)
- Creating data access layer in java (Java)
- problems with referring to class variables (Java)
- Error Creating Folder message during installation (OS X)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: plz help for encode
- Next Thread: dynamic 2 dimensional array in vb 6
Views: 3875 | Replies: 19
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
6 429 2007 access activex add age append application basic beginner birth c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






