Opening a form from a report

Locopete99

Registered User.
Local time
Today, 11:03
Joined
Jul 11, 2016
Messages
163
Hi Guys,

I'm having a bit of trouble with a Docmd.openform thats not working.


The code I have is

Code:
DoCmd.OpenForm "Frm_Enquiry B Log", acNormal, "", "JAPAN_REF=" & Me.JAPAN_REF

I just get an input box asking the value of Japan Ref

This is placed on the details property of the report.

It should open the Enquiry B log form at the record that matches the Japan Ref.

Japan Ref is my primary Key as no two references will be the same.

I have a similar report that uses

Code:
DoCmd.OpenForm "Frm_Enquiry B Log", acNormal, "", "ID=" & Me.ID

This works fine.

I've tried the following but doesn't work either

Code:
DoCmd.OpenForm "Frm_Enquiry B Log", acNormal, "", "ID=" & Me.JAPAN_REF
 
you dont open forms from reports. (you do it the other way)
Reports are dead ,flat sheets.
 
I'm sorry, I'd like to disagree.

I have a report that shows all outstanding records on a form.

This is run from a query.

I then have (on multiple times) use the aforementioned Docmd to open the specific record on a form when you click on the record on the report. This allows you to go straight to that record on the form and update it.

I'm not asking if it can be done, I'm asking if someone can check the code as it isn't working on this occasion.
 
Sorry, but I have to agree with 256...opening Forms from Reports doesn't really make much sense! But as to your problem, what is the Datatype of JAPAN_REF or JAPAN REP...and which name is correct, with the Space or with the Underline character?

If it is defined as Text, with the Underline, the syntax would be

"JAPAN_REF='" & Me.JAPAN_REF & "'"

If the name is JAPAN REP, with the Space, and is Text, you need to surround it with Square Brackets, in VBA:

"[JAPAN REF]='" & Me.[JAPAN REF] & "'"

Linq ;0)>
 
Thanks, I was missing the (').

Opening a form from a record makes sense in my Database.

The report lets people see all outstanding records.

They can then click on a single record on the report and go into the form to update.

It might be wierd, it might not be normal, but it works for what I need!!

Thanks Guys
 
Glad we could help!

FYI, if it had been a DateTime Field, the syntax would have been

"[SearchField] = #" & Me.YourControlName & "#"

Also note that the same syntax is used for all 'where' and 'criteria' clauses, including those for DCount(), DLookup(), etc.

Good luck with your project.

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom