Data control will not refresh/move to next record 
Author Message
 Data control will not refresh/move to next record

I am trying to populate a datacontrol (and some text boxes) with the results
of a parameter query.
strPrm are my query parameters and strQry is my query string.

I run query as follows:

    qTmp.SQL = strPrm & strQry 'run the query

I then define my recordset as follows:

If recSet Is Nothing Then
    Set recSet = qTmp.OpenRecordset()   'if query exists, open it, or else
Else
    recSet.Requery qTmp     'rerun query
End If

Everything seems okay and then I try to link the data control 'datDyn' to
the recordset as follows:

Set datDyn.Recordset = recSet    'define data control recordset

This is where the problem starts. I get only one record on the screen.  I
get no error messages, and when I click on the datacontrol, nothing happens.
It does not advance to the next record.  I trioed datDyn.refresh but it does
not do anything.

What am I missing?  Any help or suggestions, greatly appreciated.

The rest of my code is listed below.

Maurice I. Muoneke

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''

Option Explicit
Private dbSource, idBase As Database, recSet As Recordset, qTmp, tqDf As
QueryDef  'data handles
Dim strQry, strPrm, strdB As String 'query and parameter string handles

Private Sub cmdSearch_Click()
strdB = App.Path & "\LibraryHOH.MDB" 'define database
Set dbSource = OpenDatabase(strdB)
Set idBase = OpenDatabase(strdB)
''''''''''''''''''''''''''''
'locate and delete table if it already exists
For Each tqDf In idBase.QueryDefs   'run through entire database and delete
query
    If tqDf.Name = "infoDynamics" Then
        On Error Resume Next
        idBase.QueryDefs.Delete ("infoDynamics") 'delete query
    End If
Next tqDf

Set qTmp = dbSource.CreateQueryDef("infoDynamics")  'recreate query
strPrm = "Parameters zCatNo String, zTitle String, zAuthor1 String, " & _
    "zAuthor2 String, zAuthor3 String; "

'create query string using parameter values and field values
strQry = "SELECT * from [IFDATA] where " & _
    "(zCatNo is null or IFDATA.CatNo like zCatNo & '*') and " & _
    "(zTitle is null or IFDATA.Title like zTitle & '*') and " & _
    "(zAuthor1 is null or IFDATA.Author1 like zAuthor1 & '*') and " & _
    "(zAuthor2 is null or IFDATA.Author2 like zAuthor2 & '*') and " & _
    "(zAuthor3 is null or IFDATA.Author3 like zAuthor3 & '*') "

    qTmp.SQL = strPrm & strQry 'run the query

'define parameter values from text boxes
qTmp![zCatNo] = txtDyn(0).Text
qTmp![zTitle] = txtDyn(1).Text
qTmp![zAuthor1] = txtDyn(2).Text
qTmp![zAuthor2] = txtDyn(3).Text
qTmp![zAuthor3] = txtDyn(4).Text

If recSet Is Nothing Then
    Set recSet = qTmp.OpenRecordset()   'if query exists, open it, or else
Else
    recSet.Requery qTmp     'rerun query
End If

Set datDyn.Recordset = recSet    'define data control recordset

If datDyn.Recordset.Fields(0).Value <> "" Then 'assign field values from
recordset to text box
    txtDynView(0).Text = datDyn.Recordset.Fields(0).Value
Else
    txtDynView(0).Text = ""
End If
If datDyn.Recordset.Fields(1).Value <> "" Then 'assign field values from
recordset to text box
    txtDynView(1).Text = datDyn.Recordset.Fields(1).Value
Else
    txtDynView(1).Text = ""
End If
If datDyn.Recordset.Fields(2).Value <> "" Then 'assign field values from
recordset to text box
    txtDynView(2).Text = datDyn.Recordset.Fields(2).Value
Else
    txtDynView(2).Text = ""
End If
If datDyn.Recordset.Fields(3).Value <> "" Then 'assign field values from
recordset to text box
    txtDynView(3).Text = datDyn.Recordset.Fields(3).Value
Else
    txtDynView(3).Text = ""
End If
If datDyn.Recordset.Fields(4).Value <> "" Then 'assign field values from
recordset to text box
    txtDynView(4).Text = datDyn.Recordset.Fields(4).Value
Else
    txtDynView(4).Text = ""
End If

End Sub



Sun, 10 Dec 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Move next takes user to new record - not wanted

2. Disconnected Recordset will not move to the next record

3. Data Control & Move Next method

4. How to move to the next record?

5. Disable move to prev/next record when turning mouse wheel

6. How to move to the next record

7. How to make combo box move to next record

8. Doing Error Checking before moving to next record

9. Move Next Record

10. How to move to the next record?

11. Move to next record in DAO

12. (Programming)How to get parent control or move next control of radiobutton

 

 
Powered by phpBB® Forum Software