Question : trouble with displaying recordset results in datasheet view

See my code below. I have successfully connected to the database and I am pulling a recordset. Depending on the value I put in my text box, my recordet has a different number of records.

My problem is displaying the data to the user. I am trying to display the results on a form in Datasheet view. However, when the form opens, there is no data displayed, only a column of squares down the left representing each record. If my recordset has 3 records, I get 4 boxes. If my recordset has 61 records, I see 62 boxes.

WHat am I doing wrong?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
Dim strSQL As String
strSQL = "SELECT tblSerialNo.SerialNo, tblSerialNo.ModelNo, tblWarrantyCard.* "
strSQL = strSQL & "FROM tblSerialNo INNER JOIN tblWarrantyCard ON tblSerialNo.RecID = tblWarrantyCard.RecID "
strSQL = strSQL & "WHERE tblSerialNo.SerialNo LIKE '%" & Me.txtSerial & "%'"
 
  Dim conn As New ADODB.Connection
  Dim rs As New ADODB.Recordset
  
  Call conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=\\server\share\leads.mdb;", "Admin", "")
  Call rs.Open(strSQL, conn, adOpenStatic, adLockOptimistic)
  If rs.RecordCount > 0 Then
    msgbox rs.RecordCount
  Else
    msgbox rs.RecordCount
  End If
  
  DoCmd.OpenForm "frmWarrSerialDisplay", acFormDS, , , acFormReadOnly
Set Forms![frmWarrSerialDisplay].Recordset = rs
  
  
  rs.Close
  conn.Close

Answer : trouble with displaying recordset results in datasheet view

Well ok ... this first problem is ... there are *no* controls on the form to display the data!
Also, the Default View was set to Single Form.

I also add this to the button code:

DoCmd.Restore

see attached file

 
s/b working
 
Random Solutions  
 
programming4us programming4us