Subform Creating an edit button

TheViruz30

Registered User.
Local time
Today, 14:39
Joined
Jan 21, 2006
Messages
33
Main form is frmPeople

As you can see i have a subform called frmPeopleInsurancesSub
Next to that I have a Edit Command button which open a forms called
PeopleInsurances

When user wants to edit one of the insurances all user has to do is click on on one of the insurance and click edit to take user to that record

But cant make it work


Any Ideas
 

Attachments

You need to pass link criteria, similar to what you did in the On Clivk event of your Add Insurance button (which, by the way, you don't need ;)

RV
 
Dont know how

I dont know how to link the subform or create a pass critera

Do you have a sample
 
I tried using the contactID in the subform as the criteria but dosnt recongized it
 
there re many trouble from your Program !

First, PersonID(combobox in your SubForm) 's setting is wrong about column number.
That's why PersonID is showing in this Subform is different with PersonID in mainform !
Tell the true, it not necessary to make PersonID as a combobox in Subform . You should make it in the Main Form , that looks more clearly !
And it is the sama with [InsuranceName] in the SubForm !

2nd,

Code:
Private Sub Edit_Click()
On Error GoTo Err_Edit_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmPeopleInsurance"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Edit_Click:
    Exit Sub

Err_Edit_Click:
    MsgBox Err.Description
    Resume Exit_Edit_Click
    
End Sub

with this code , your Edit Form cannot show anything or just show what that form was set --> coz stLinkCriteria has not value !

Look at your addinsurance button 's Code

Code:
Private Sub Add_Insurance_Click()
On Error GoTo Err_Add_Insurance_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmPeopleInsurance"
    stLinkCriteria = "[PersonID]=" & Me![PersonID] [COLOR="DarkGreen"]'<--- this one will be shown when you click Edit button ! 
However it s also wrong cuz Me![PersonID] is in your main form is not what the users click on your Subform ![/COLOR]
    DoCmd.OpenForm stDocName, , , stLinkCriteria 

Exit_Add_Insurance_Click:
    Exit Sub

Err_Add_Insurance_Click:
    MsgBox Err.Description
    Resume Exit_Add_Insurance_Click
    
End Sub

So there re more but is not important! Just correct these one ... your program will be fine ! There re alot of sample for you in this forum (search it pls :D).So i do not need to write more ! Good luck ! anything i can help ... you're welcome !
 

Users who are viewing this thread

Back
Top Bottom