Solved open form with button on main form with selection of subform

silentwolf

Active member
Local time
Today, 11:58
Joined
Jun 12, 2009
Messages
644
Hi guys,

can't find the post and was wondering if someone can tell me if that code is correct?

I have a main form in the header I have a button.
in the detail secton I have a subform.

This is the code I am useing.

Code:
    If IsNull(Me!sfmAllCustomers!CustID) Then
        MsgBox "Bitte wählen Sie zunächst einen Datensatz aus."
        Exit Sub
    End If
    DoCmd.OpenForm "frmCustomers", datamode:=acFormEdit, _
                    WindowMode:=acNormal, _
                    WhereCondition:="CustomerID=" & Me!sfmAllCustomers!CustomerID      'Sollte passen??
    Me.Requery

Ths subformn is a continious form.

So could someone tell me if that is correct or is there a better way of doing this?

sorry it is a datasheet subform!!
Many thanks
 
all your Parameter on opening the frmCustomers form, have Parameter Name on it.
so you also add Parameter Name to your form (FormName)


DoCmd.OpenForm FormName:="frmCustomers", datamode:=acFormEdit, _
WindowMode:=acNormal, _
WhereCondition:="CustomerID=" & Me!sfmAllCustomers!CustomerID 'Sollte passen??
 
So you don't need requery?

And is it also the same in an endless subform?

Cheers
 
what is correct CustID or CustomerID?
 
CustomerID is correct.

It opens ok without me.requery

and for double click event I have following
Code:
        If IsNull(Me!CustID) Then

            MsgBox "Bitte wählen Sie zunächst einen Datensatz aus."

            Exit Sub

        End If
        
        DoCmd.OpenForm "frmCustomers", datamode:=acFormEdit, _

            WindowMode:=acWindowNormal, WhereCondition:="CustomerID=" & Me!CustomerID
            

        Me.Requery

 
hmm I am not sure why it did

Now I did change it to if isNull (me!CustomerID)...
 
it is of no use to Requery when the form you just opened is not in Dialog mode (WindowMode:=acDialog)
 
ah ok..

So when do you use what?

I mean I can always edit the form can't I ?
 

Users who are viewing this thread

Back
Top Bottom