parameter passing to queries through VBA. please read.

saleemMSMS

Registered User.
Local time
Today, 21:44
Joined
Aug 12, 2009
Messages
92
consider the following tables
2hdyuy8.png


i have 2 interfaces for the above 2 tables.
the training attendance is a subform of the training program form.
and the form looks like follows
2rnvvk9.png


the training sesssion sub form saves data as follows.
(i.e the sesion id starts again from 1 for a new program id)
vowr34.jpg


in the interface, entering of sessionID should be done manually. so in order to make it somewhat automated, i wrote the following query
Code:
select max(sessionID)+1 
from trainingProgram inner join trainingSessions on
trainingProgram.programID=trainingSessions.programID
where programID=forms!trainingProgram!programID

this is saved in the query named TrainingSessionIncrement and this works well if run individually. but when i included it into the double click event of trainingSessionID text box,

Code:
Private Sub TrainingSessionID_DblClick(Cancel As Integer)
forms!trainingProgram!programID.setfocus
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("TrainingSessionIncrement") 'this is the queryName
TrainingSessionID.Text = rs(0)
rs.Close
Set rs = Nothing
End Sub

the following error occurs.
Run-Time Error'3061'
Too Few Parameters. Expected 1.


what shall i do ? please correct me.
 
Hello saleem!
Look at "DemoParameterPassingA2000.mdb" (attachment, zip).
Open "frmTrainingProgramsMain", and try.
 

Attachments

Hello saleem!
Look at "DemoParameterPassingA2000.mdb" (attachment, zip).
Open "frmTrainingProgramsMain", and try.

wow !! it works well bro !!thanx for the coding nd time spent to this..
may i know how did u disabled the text boxes ??
coz i did it once and an error popped saying u cannot insert values for disabled controls..
FYI i'm using Access 2007


Thanx again :)
 
About disabled. In properties ENABLED put No. (contrary is Yes).
 

Users who are viewing this thread

Back
Top Bottom