-
C'mon have a look at this will ya!!
I need some help..
I got an SQL string (i think it works) to be executed as a query search on a table but i cant get the msflexgrid to refresh or the data control for that matter. This is the code:
Dim SQL As String
SQL = "Select * from [cd_serial_numbers] where [band_name] = '" & txtband.Text & "'"
Let Data1.RecordSource = SQL
Data1.Refresh
MSFlexGrid1.Refresh
Data1.Refresh
MSFlexGrid1.DataSource = Data1
MSFlexGrid1.Refresh
which lines of code do i need and which don't i need?
Please i am desperate....
-
It seems like your refreshing it a lot of times...
try:
Code:
Dim SQL As String
SQL = "Select * [rom cd_serial_numbers] where [band_name] = ' " & txtband.Text & " ' "
Let Data1.RecordSource = SQL
Data1.Refresh
MSFlexGrid1.DataSource = Data1
MSFlexGrid1.Refresh
Try that out...i don't know much about DB but that did look a bit strange.
Hope that helps,
D!m
-
ok i dropped the DAO option and i am now using ADO with a datagrid and adodc its all set up and everything but now the connection doesnt work.
I did the same at school with the same provider and everything (cept the path of the db) and it worked at school. What is wrong with it?
Data link error when i try and test the connection.
'Test connection failed because of an error in intialising provider. Unspecified error..
What does this mean?
oh and this is my search code now.
Dim search As String
Dim band As String
Dim album As String
Dim genre As String
Dim cdtype As String
Dim released As String
Dim company As String
Dim serial As String
On Error GoTo damn
band = Trim(txtband.Text)
album = Trim(txtalbum.Text)
genre = Trim(txtgenre.Text)
cdtype = Trim(txttype.Text)
released = Trim(txtreleased.Text)
company = Trim(txtcompany.Text)
serial = Trim(txtserial.Text)
search = "select *"
search = search & "from cd_serial_numbers"
If Len(band) Then
If blnsearch Then
search = search & "or"
Else
search = search & "where"
blnsearch = True
End If
search = search & "(band_name ='" & txtband.Text & "')"
End If
If Len(album) Then
If blnsearch Then
search = search & "or"
Else
search = search & "where"
blnsearch = True
End If
search = search & "(album_name ='" & txtalbum.Text & "')"
End If
If Len(genre) Then
If blnsearch Then
search = search & "or"
Else
search = search & "where"
blnsearch = True
End If
search = search & "(genre ='" & txtgenre.Text & "')"
End If
If Len(cdtype) Then
If blnsearch Then
search = search & "or"
Else
search = search & "where"
blnsearch = True
End If
search = search & "(single/album ='" & txttype.Text & "')"
End If
If Len(released) Then
If blnsearch Then
search = search & "or"
Else
search = search & "where"
blnsearch = True
End If
search = search & "(released ='" & txtreleased.Text & "')"
End If
If Len(company) Then
If blnsearch Then
search = search & "or"
Else
search = search & "where"
blnsearch = True
End If
search = search & "(company ='" & txtcompany.Text & "')"
End If
If Len(serial) Then
If blnsearch Then
search = search & "or"
Else
search = search & "where"
blnsearch = True
End If
search = search & "(serial ='" & txtserial.Text & "')"
End If
Debug.Print search
Adodc1.RecordSource = search
Adodc1.Refresh
damn = MsgBox("Something has gone wrong (duh)!")