这些线上的东西应该适合。这是一个带有子窗体的未绑定窗体。
您可以从表单向导
要正常工作,获取表单类型,你将需要一些代码,说:
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