Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I was wondering what are my option for display data onto a bound form from a query made from ado/sql (code below). I know I can code the data into the text boxes by pulling out the field I require but is there an easier option? i was looking into Bookmarks but mine dose not seem to work, so don't know if im doing something wrong. Any help would be great

Thanks

Dave

Code

If IsNull(Text151) Or IsNull(Text155) Then Exit Sub
  
Dim rstCustomer As ADODB.Recordset
Dim conn As ADODB.Connection
Dim strconn As String
Dim strSQL As String

  
  'Create a connection to the current database
    Set conn = CurrentProject.Connection
'Create the recordset and fill it
    Set rstCustomer = New ADODB.Recordset
    strSQL = "SELECT * FROM Member_Details Where Member_Details.[Firstname] = '" & Text155.Value & "' And Member_Details.[Surname] = '" & Text151.Value & "';"
    rstCustomer.Open strSQL, conn, adOpenStatic, adLockBatchOptimistic
  
  'Move Record to last to coutn and then back to the first rec
   rstCustomer.MoveLast
    noofrecords = rstCustomer.RecordCount
    rstCustomer.MoveFirst

Me.Bookmark = rstCustomer.BookmarkIf IsNull(Text151) Or IsNull(Text155) Then Exit Sub
    'Dim rs As DAO.Recordset
    'Set rs = Me.RecordsetClone
  'rs.FindFirst "[Surname]=""" & Text151 & """"
  
Dim rstCustomer As ADODB.Recordset
Dim conn As ADODB.Connection
Dim strconn As String
Dim strSQL As String

  
  'Create a connection to the current database
    Set conn = CurrentProject.Connection
'Create the recordset and fill it
    Set rstCustomer = New ADODB.Recordset
    strSQL = "SELECT * FROM Member_Details Where Member_Details.[Firstname] = '" & Text155.Value & "' And Member_Details.[Surname] = '" & Text151.Value & "';"
    rstCustomer.Open strSQL, conn, adOpenStatic, adLockBatchOptimistic
  
  'Move Record to last to coutn <code></code>and then back to the first rec
   rstCustomer.MoveLast
    noofrecords = rstCustomer.RecordCount
    rstCustomer.MoveFirst

Me.Bookmark = rstCustomer.Bookmark

rstCustomer.Close
   Text151 = Null
   Text155 = Null


note: not finished my if statement yet
Posted

1 solution

Today I get to answer my own question,lol (type the right key words in google this time).

To set the form recordset property to the ado record set use the following:-

Set me.recordset = rs 



so using the code above my code would look like

Set me.recordset = rstCustomer


Hope this helps anyone with the same problem

Dave:thumbsup:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900