Wilder1626
asked on
Microsoft Access to VB6 MsFlexfrid
Hello all.
I need your help with a search tool in VB6.
I have a calendar and a common button. I would like to select a date and when i would click on the button, it would search in my Access db in the first column called "Date", and brign all the line in my MSFlexgrid1.
How can i do this?
Since i dont know what info i need to tell you, here is the code that i have to feed a combo box in the same form.
Thanks again for your help
I need your help with a search tool in VB6.
I have a calendar and a common button. I would like to select a date and when i would click on the button, it would search in my Access db in the first column called "Date", and brign all the line in my MSFlexgrid1.
How can i do this?
Since i dont know what info i need to tell you, here is the code that i have to feed a combo box in the same form.
Thanks again for your help
Private Sub Form_Load()
Dim sSQL2 As String
Dim oConnect2 As ADODB.Connection
Set oConnect2 = New ADODB.Connection
Dim oRST2 As ADODB.Recordset
Set oRST2 = New ADODB.Recordset
sSQL2 = "SELECT [Produits]FROM [Description produit]'"
oConnect2.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & Form4.txtBaseDe.Text
oRST2.Open sSQL2, oConnect2
Do Until oRST2.EOF
Des_prod.AddItem oRST2("Produits")
oRST2.MoveNext
Loop
End Sub
ASKER
Would it be easier with a Datagrid?
The only problem is that i dont want to be able to change data in the datagrid from the datagrid directely.
Thanks again for your help
The only problem is that i dont want to be able to change data in the datagrid from the datagrid directely.
Thanks again for your help
Which of your columns is a date? What is the Calendar control for?
AW
AW
ASKER
The first column is the row number, and the seconde column is the date format dd mmmm yyyy.
I just created a combobox: ComDateDisponible
In that combobox, it give me the dates in that column.
So if i could filter with that combobox, it would be great.
Thanks
I just created a combobox: ComDateDisponible
In that combobox, it give me the dates in that column.
So if i could filter with that combobox, it would be great.
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The date is set as text. Is that an issue?
My regional setting is French canada also.
My regional setting is French canada also.
ASKER
Is that a good start?
Dim sSQL2 As String
Dim oConnect2 As ADODB.Connection
Set oConnect2 = New ADODB.Connection
Dim oRST2 As ADODB.Recordset
Set oRST2 = New ADODB.Recordset
sSQL2 = "SELECT [Période], [Description_du_produit], [Quantité_commandée], [Quantité_reçue ], [Composante_1], [Quantité_Comp_1], [Quantité_reçue_comp_1] FROM [Inventaire] Where [Periode] = '" & ComDateDisponible.Text & "'"
oConnect2.Open "Provider=Microsoft.ACE.OL EDB.12.0;" & _
"Data Source=" & Form4.txtBaseDe.Text
oRST2.Filter = "Période='" & ComDateDisponible.Text & "'"
I'm just stuck there for now.
Dim sSQL2 As String
Dim oConnect2 As ADODB.Connection
Set oConnect2 = New ADODB.Connection
Dim oRST2 As ADODB.Recordset
Set oRST2 = New ADODB.Recordset
sSQL2 = "SELECT [Période], [Description_du_produit], [Quantité_commandée], [Quantité_reçue ], [Composante_1], [Quantité_Comp_1], [Quantité_reçue_comp_1] FROM [Inventaire] Where [Periode] = '" & ComDateDisponible.Text & "'"
oConnect2.Open "Provider=Microsoft.ACE.OL
"Data Source=" & Form4.txtBaseDe.Text
oRST2.Filter = "Période='" & ComDateDisponible.Text & "'"
I'm just stuck there for now.
ASKER
This is where i am now but i have an error Run-Time error '-2147217904 (80040e10)':
Dim sSQL2 As String
Dim oConnect2 As ADODB.Connection
Set oConnect2 = New ADODB.Connection
Dim oRST2 As ADODB.Recordset
Set oRST2 = New ADODB.Recordset
sSQL2 = "SELECT [Période], [Description_du_produit], [Quantité_commandée], [Quantité_reçue ], [Composante_1], [Quantité_Comp_1], [Quantité_reçue_comp_1] FROM [Inventaire] Where [Periode] = '" & ComDateDisponible.Text & "'"
oConnect2.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & Form4.txtBaseDe.Text
oRST2.Filter = "Période='" & ComDateDisponible.Text & "'"
oRST2.Open sSQL2, oConnect2
Do Until oRST2.EOF
MSFlexGrid1.AddItem oRST2("Période") & ""
oRST2.MoveNext
Loop
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello game master,
I have change some detail but still does not work:
I still have:Run-Time error '-2147217904 (80040e10)':
and it put in yellow that part of the code: oRST2.Open sSQL2, oConnect2.
If i put my mouse under "If oRST2.BOF" , it says: Operation is not allowed when the object is closed.
Do you know what that is?
Thanks
I have change some detail but still does not work:
I still have:Run-Time error '-2147217904 (80040e10)':
and it put in yellow that part of the code: oRST2.Open sSQL2, oConnect2.
If i put my mouse under "If oRST2.BOF" , it says: Operation is not allowed when the object is closed.
Do you know what that is?
Thanks
Dim sSQL2 As String
Dim oConnect2 As ADODB.Connection
Set oConnect2 = New ADODB.Connection
Dim oRST2 As ADODB.Recordset
Set oRST2 = New ADODB.Recordset
oConnect2.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & Form4.txtBaseDe.Text
sSQL2 = "SELECT [Période],[No_Bon],[Pays] FROM [Inventaire] Where yourDateField = '" & ComDateDisponible.Text & "'"
oRST2.Open sSQL2, oConnect2
If oRST2.BOF = False Then
Do Until oRST2.EOF
With MSFlexGrid1
'do the this if u have multiple field to add on your flexgrid
.AddItem oRST2("Période") & vbTab & oRST2("No_Bon") & vbTab & oRST2("Pays")
oRST2.MoveNext
End With
Loop
Else
'no record found...do something here
End If
ASKER
I have it. I change the sSQL2 with:
sSQL2 = "SELECT [Période],[No_Bon],[Pays] FROM [Inventaire] Where Période = '" & ComDateDisponible.Text & "'"
Now it work.
Thanks alout for your help.
Best regards
sSQL2 = "SELECT [Période],[No_Bon],[Pays] FROM [Inventaire] Where Période = '" & ComDateDisponible.Text & "'"
Now it work.
Thanks alout for your help.
Best regards
ASKER
Thanks
sorry for the late reply...
was out and i just read your comment..
Im glad i could help you..
Thanks for the points..
game-master
ASKER
I have a Calendar: Calendar1.
I also have a Flexgrid: MSFlexGrid1
When i select a date, i want to import from my Microsoft access database want was entered on the same date.
The origine of my Microsoft access is:
oConnect2.Open "Provider=Microsoft.ACE.OL
"Data Source=" & Form4.txtBaseDe.Text
The columns are:
sSQL2 = "SELECT [Période], [Description_du_produit], [Quantité_commandée], [Quantité_reçue ], [Composante_1], [Quantité_Comp_1], [Quantité_reçue_comp_1] FROM [Inventaire]'"
I hope this could help.
Thanks again for your help