Open form with filter help

G

Guest

Hi,
Need help to write a filter that opens a form at the right place.
Using 'Docmd.Openform "Cust_Edit_Form" and cannot figure out the form filter
where a valid 'WHERE" is valid.

Trying to get the form to open based on the working forms feild
"CompanyName" so that [Forms]![Cust_Edit_Form]![CustomerName] is equal to the
feild "Me![CompanyName]".
 
D

Damon Heron

I hope that is a typo on your part. CustomerName= CompanyName? Well,
maybe they are the same, but if so, why not name them the same? Also -use
the unique record ID instead of name. Anyway, in the load event of the
form:
DoCmd.openform "Cust_Edit_Form", acNormal, , "CustomerID = " & Me!CompanyID,
acFormEdit, acDialog


HTH
Damon
 
N

niuginikiwi

Try the air code below on the double click event property of your
CompanyName field and double click company name at runtime.

Private Sub CompanyName_DblClick(Cancel As Integer)
'View Customer filtered to the current CompanyName
DoCmd.OpenForm "Cust_Edit_Form"
If Me![CompanyName] > 0 Then
DoCmd.GoToControl "CompanyName"
DoCmd.FindRecord Me![CompanyName]
Else
If Not IsNull(Forms![Cust_Edit_Form]![CustomerName]) Then
DoCmd.DoMenuItem acFormBar, 3, 0, , acMenuVer70
End If
End If
End Sub
 
G

Guest

Thanks Damon.
The feilds have different names, its what happens when 2 tables are done at
different times and places unfortunately
--
Regards
Bill


Damon Heron said:
I hope that is a typo on your part. CustomerName= CompanyName? Well,
maybe they are the same, but if so, why not name them the same? Also -use
the unique record ID instead of name. Anyway, in the load event of the
form:
DoCmd.openform "Cust_Edit_Form", acNormal, , "CustomerID = " & Me!CompanyID,
acFormEdit, acDialog


HTH
Damon

justagrunt said:
Hi,
Need help to write a filter that opens a form at the right place.
Using 'Docmd.Openform "Cust_Edit_Form" and cannot figure out the form
filter
where a valid 'WHERE" is valid.

Trying to get the form to open based on the working forms feild
"CompanyName" so that [Forms]![Cust_Edit_Form]![CustomerName] is equal to
the
feild "Me![CompanyName]".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top