Access 2010에서 동적 통과 쿼리를 사용하여 백 엔드 데이터베이스에서 레코드를 하나 이상 검색합니다. 많은 시행 착오 끝에 적합한 레코드를 검색하고 OnLoad 이벤트 중에 데이터 시트 형식의 언 바운드 텍스트 상자에 할당 할 수있는 적절한 코드를 표절했습니다. 남은 유일한 문제는 여러 레코드를 표시하는 것입니다. 각 레코드의 필드 내용이 폼의 텍스트 상자 컨트롤에 저장된 이전 값을 덮어 씁니다. 그래서 어디서나 볼 수있을 것으로 예상되면 데이터 시트에 표시된 단일 레코드로 끝납니다 1에서 10까지.Access 2010 : 데이터 시트의 언 바운드 컨트롤에 여러 레코드 내용 표시
나는 그것이 간단한 해결책이라고 확신한다. 누군가 내게 그것을 지적하시기 바랍니다 수 있습니까?
Private Sub Form_Load()
Dim sqlString As String
sqlString = "SELECT Transmitter_ID, Receiver_ID, UTC_Date, Local_Date from Detections"
If Not IsNull(Me.OpenArgs) Then
sqlString = sqlString & " where " & OpenArgs
End If
Dim cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rst As ADODB.Recordset
'Define and open connection
cnn.ConnectionString = "DRIVER={SQLite3 ODBC Driver};Database=z:\EWAMP\EWAMP_be_dev.sqlite"
cnn.Open
'Define ADO command
cmd.ActiveConnection = cnn
cmd.CommandText = sqlString
'Populate and enumerate through recordset
Set rst = cmd.Execute
If rst.EOF Then
MsgBox "Nothing found...", vbInformation + vbOKOnly
Exit Sub
Else
Do While Not rst.EOF
'// I'm guessing the problem is with my control assignments, here.
Me.cntl_Receiver_ID.Value = rst("Receiver_ID")
Me.cntl_Transmitter_ID.Value = rst("Transmitter_ID")
Me.cntl_UTC_Date.Value = rst("UTC_Date")
Me.cntl_Local_Date.Value = rst("Local_Date")
Debug.Print {Show me the four control values}
rst.MoveNext
Loop
End If
End Sub
건배! 나는 데이터 시트보기에서 폼을 믿지 않는