显示查询到绑定控件表单上的数据时出现问题

显示查询到绑定控件表单上的数据时出现问题

本文介绍了显示查询到绑定控件表单上的数据时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想知道从ado/sql(以下代码)查询中将数据显示到绑定表单上的选项是什么.我知道我可以通过拉出我需要的字段将数据编码到文本框中,但是有没有更简单的选择?我一直在研究书签",但是我的似乎不起作用,所以不知道即时消息是否做错了.任何帮助都很好

谢谢

戴夫

代码

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



注意:尚未完成我的if语句



note: not finished my if statement yet

推荐答案

Set me.recordset = rs 




所以使用上面的代码看起来像




so using the code above my code would look like

Set me.recordset = rstCustomer



希望这对遇到同样问题的人有所帮助

Dave:thumbsup:



Hope this helps anyone with the same problem

Dave:thumbsup:


这篇关于显示查询到绑定控件表单上的数据时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 21:55