From: Song on 27 Apr 2010 16:30 Private Sub Sect_BeforeUpdate(Cancel As Integer) Dim db As dao.Database Dim rst As dao.Recordset Set rst = CurrentDb.OpenRecordset("Select * From qryData Where [sect] = '" & Me.Sect _ & "' And [TimeIn] >= #" & [Forms]![MainMenu].[From] & _ "# And [TimeOut] <= #" & [Forms]![MainMenu].[To] + 1 & "#") If rst.EOF Then MsgBox Me.Sect & " is not valid section #, or" & vbCrLf _ & "no student signed in " & Me.Sect & " during the period specified.", , conAppName Cancel = True Else Me.Course = rst![Course] End If Set db = Nothing Set rst = Nothing Exit_sect_BeforeUpdate: Exit Sub Err_sect_BeforeUpdate: MsgBox Err.Description Resume Exit_sect_BeforeUpdate End Sub Above code generate error message. Help is needed. Thanks.
From: ghetto_banjo on 27 Apr 2010 16:49 Does qryData have parameters? If so, those parameters need to be resolved first before the OpenRecordSet command.
From: Song on 27 Apr 2010 17:27 On Apr 27, 1:49 pm, ghetto_banjo <adam.v...(a)gmail.com> wrote: > Does qryData have parameters? If so, those parameters need to be > resolved first before the OpenRecordSet command. I solved parameters in qryData and simplified OpenRecordSet as follows: Set rst = CurrentDb.OpenRecordset("Select * From qryData Where [sect] = '" & Me.Sect & "'") But I still get same error message.
From: Roger Carlson on 28 Apr 2010 08:27 How did you "solve the parameters" in qryData? It doesn't sound as if you've done that at all. You might want to take a look at a sample on my website called TooFewParameters.mdb (http://www.rogersaccesslibrary.com/forum/topic234.html) which not only explains why you're getting the "Too Few Parameters" error, but a couple of ways to fix it. It strike me that you either need to use a querydef to recreate qryData before creating your recordset or you need to read the parameters collection. BTW, since you are creating a database variable, you might as well use it: Dim db As dao.Database Dim rst As dao.Recordset Set db = CurrentDb Set rst = db.OpenRecordset("Select * From qryData Where [sect] = '" & Me.Sect _ ... -- --Roger Carlson MS Access MVP Access Database Samples: www.rogersaccesslibrary.com Want answers to your Access questions in your Email? Free subscription: http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L "Song" <song.usa(a)gmail.com> wrote in message news:cca3436b-e58e-4a38-802c-e0f4af19faac(a)v12g2000prb.googlegroups.com... On Apr 27, 1:49 pm, ghetto_banjo <adam.v...(a)gmail.com> wrote: > Does qryData have parameters? If so, those parameters need to be > resolved first before the OpenRecordSet command. I solved parameters in qryData and simplified OpenRecordSet as follows: Set rst = CurrentDb.OpenRecordset("Select * From qryData Where [sect] = '" & Me.Sect & "'") But I still get same error message.
|
Pages: 1 Prev: Has anyone seen this? Next: how do I strip spaces and replace with dashes |