這些線上的東西應該適合。這是一個帶有子窗體的未綁定窗體。
您可以從表單嚮導
要正常工作,獲取表單類型,你將需要一些代碼,說:
Private Sub cmdGo_Click()
Dim rs As DAO.Recordset
Dim sSQL As String
Dim sSDate As String
Dim sEDate As String
sSDate = "#" & Format(Me.txtStartDate, "yyyy/mm/dd") & "#"
sEDate = "#" & Format(Me.txtStartDate + Me.txtNoDays, "yyyy/mm/dd") & "#"
sSQL = "SELECT * FROM MyTable WHERE DataDate Between " & sSDate _
& " AND " & sEDate
Set rs = CurrentDb.OpenRecordset(sSQL)
If rs.RecordCount < Me.txtNoDays Then
AddRecords sSDate, sEDate
End If
Me.DataSubform.Form.RecordSource = sSQL
End Sub
Sub AddRecords(sSDate, sEDate)
''Uses counter table with integers from 0 to
''highest required number
''Another useful table is a calendat table, which would
''save some work here.
sSQL = "INSERT INTO MyTable (DataDate) " _
& "SELECT AddDate FROM " _
& "(SELECT " & sSDate _
& " + [counter.ID] AS AddDate " _
& "FROM [Counter] " _
& "WHERE " & sSDate _
& "+ [counter.ID] Between " & sSDate _
& " And " & sEDate & ") a " _
& "WHERE AddDate NOT In (SELECT DataDate FROM MyTable)"
CurrentDb.Execute sSQL, dbFailOnError
End Sub
在極致簡約,使用數據表格或連續的表格。您可以考慮使用主/明細配置。 – HK1 2012-04-09 13:14:02
@ HK1,謝謝。我看不出連續的表格是如何工作的,但(顯然)我是新手。 Access(2003)幫助不包含「數據表格」的任何條目。 – CarlF 2012-04-09 13:52:01
它可能被稱爲數據表視圖 – HK1 2012-04-09 15:00:14