Subform and FindRecord

snewham

New member
Local time
Today, 10:41
Joined
Jan 18, 2007
Messages
4
:eek: :confused: Hi, I am currently doing an A2 level Coursework on Information Systems and part of this embodies a database and I am have a few issues with a certain aspect of the database that I am currently building.



The three forms that concern this answer are: "Frm_Main", "Frm_Customer" and "Frm_Projects".


"Frm_Main" is the main database form with a subform ("Sub_Main") displaying the content and buttons to the right for navigation etc.

Basically, within the "Frm_Customer" form that is viewed within the subform on the "Frm_Main" form there is another subform, this time showing projects specifically for that Customer.

I want to be able to select a record from the table, click a button and the "Frm_Projects" will open within the main subform on "Frm_Main" and use FindRecord to navigate to the record that was selected.

At the moment, I have it working properly, however instead of the "Frm_Projects" openning within the subform it opens as a new form.

This is the code that I am currently using for the button on the "Frm_Customer":


Code:
Private Sub openrecord_Click()
On Error GoTo Err_openrecord_Click
    If Forms![Frm_Main]![Sub_Main]![project_subform].Form.RecordsetClone.RecordCount = 0 Then
        MsgBox "There are no proposed projects entered for this Client."
    Else
        DoCmd.OpenForm "project_form"
        DoCmd.FindRecord Forms![Frm_Main]![Sub_Main]![project_subform].Form![Project ID]
        
    End If

Exit_openrecord_Click:
    Exit Sub

Err_openrecord_Click:
    MsgBox Err.Description
    Resume Exit_openrecord_Click
End Sub


As you can see, I have also implemented an error message to generate if there are no records entered within the table subform.



If it's any use, here is the code I am using for the buttons on the "Frm_Main" to change the source of the subform ("Sub_Main")



Code:
Sub_Main.SourceObject = "Frm_Customers"



Thankyou, ever so much for your time and it will be muchly appreciated. :p

Scott
 

Users who are viewing this thread

Back
Top Bottom