Form Question

kinger88

New member
Local time
Today, 19:54
Joined
Jul 29, 2008
Messages
6
Hi,
I have created this form

Form.jpg


What i want it to do is...
When i click the button "View Learners" it brings up another form with the details of the course selected in the subform so in the pic it would bring up details of the manual handing course.
I'm not a programmer i only use macro's as present so the way i have tried to do it is through openForm and with a condition but this has trouble as there is obviously more than 1 record in the subform and i only want it to match the selected one.

Any help would be great.
Cheers
 
There are a couple of simple ways to isolate the record.

Firstly, in your Where clause do AND with two fields. For example I just pulled this off one of my macros

([CLSurname]=[Forms]![MasterForm]![CLSurname]) And ([CLDOB]=[Forms]![MasterForm]![CLDOB]) Thus both surname and date of birth must match. For yours it might be the ID and Course Name.

Another way is to add a field to your query or queries that joins two of the fields. With the query in design view add to the field row a new field as in

NewFieldName:[IDField] & "" & [CourseName] and then base your where clause on this new field.
 
Here's an idea for you... I lose the record indicators, I simply don't think they look professional, and I make the text in the field blue.
A blue field in my apps means you can double click for more info... then insert this code
Code:
Private Sub CourseNameID_DblClick(Cancel As Integer)

On Error GoTo Err_CourseNameID_DblClick

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmWhatever"
    
    stLinkCriteria = "[CourseNameID]=" & Me![CourseNameID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_CourseNameID_DblClick:
    Exit Sub

Err_CourseNameID_DblClick:
    MsgBox Err.Description
    Resume Exit_CourseNameID_DblClick
    
End Sub
This assumes you have a field named "CourseNameID"
Just another option for you to consider.
 
Last edited:
Are you looking for details of the course itself or the employee's status regarding the course ie taken at Kings Rd College etc?
 
Still can't get this one to work.

Just to be clear what i want to happen is for the user to select one of the courses in the subform e.g. Manual Handling on 17/4/08 is selected in the picture.

Then i want the user to be able to click on the button view learners which will bring up another form with that specific course and the learners which were on the course.

I have got an ID for each of the courses which is hidden so what i want is the ID of the selected course in the subform to match the ID in the other form to bring up the details but im not sure how to select the single record in the subform in my macro.
 
Figured it out through trial and error eventually
Thanks
 

Users who are viewing this thread

Back
Top Bottom