Open a record in form based from a datasheet double click (1 Viewer)

andy_dyer

Registered User.
Local time
Today, 02:02
Joined
Jul 2, 2003
Messages
806
Hi,

I've seen a few posts around this subject but none seem to hit the spot I need..

I've seen pbaldy's link;

http://www.baldyweb.com/wherecondition.htm

And I'm trying to use it BUT...

I need to pass two parameters in...

Using the above link my code is

Code:
DoCmd.OpenForm "frmProjectFinanceYearDetail", , , "txtYear = " & Me.Year & "'"

But I get the following error;

Run-time error '3075':

Syntax error in string in query expression 'txtYear = 2011".

I'm not sure if that's because I need to pass into the equation the ProjectID as well as the Year in roder to open the correct form?

Any ideas what I've done wrong?

Many thanks
 

John Big Booty

AWF VIP
Local time
Today, 11:02
Joined
Aug 29, 2005
Messages
8,263
You appear to be missing an apostrophe;

Code:
DoCmd.OpenForm "frmProjectFinanceYearDetail", , , "txtYear = [B][COLOR="Red"]'[/COLOR][/B]" & Me.Year & "'"
 

pr2-eugin

Super Moderator
Local time
Today, 02:02
Joined
Nov 30, 2011
Messages
8,494
You do have a syntax error in your statement.. you have..
Code:
DoCmd.OpenForm "frmProjectFinanceYearDetail", , , "txtYear = " & Me.Year & "[COLOR=Red][B] ' [/B][/COLOR]"
Remove the single quote.. your syntax will be correct..
 

andy_dyer

Registered User.
Local time
Today, 02:02
Joined
Jul 2, 2003
Messages
806
Thanks both - I've treied both ways and it gets rid of my syntax error and now opens the form but not for the record I want - just a blank form...

I think I've followed the guidance pbaldy has in his link but can't get to the right record...

Any ideas?
 

John Big Booty

AWF VIP
Local time
Today, 11:02
Joined
Aug 29, 2005
Messages
8,263
You do have a syntax error in your statement.. you have..
Code:
DoCmd.OpenForm "frmProjectFinanceYearDetail", , , "txtYear = " & Me.Year & "[COLOR=Red][B] ' [/B][/COLOR]"
Remove the single quote.. your syntax will be correct..

Given that his field txtYear would appear to be a text field that is incorrect he would need to add a second apostrophe inside the double quotes enclosing txtYear = and to the right of the equal sign.
 

pr2-eugin

Super Moderator
Local time
Today, 02:02
Joined
Nov 30, 2011
Messages
8,494
Yes John, I understand, but I felt as Andy is using a Year value I guessed it might be an Integer.. I might be wrong..
 

andy_dyer

Registered User.
Local time
Today, 02:02
Joined
Jul 2, 2003
Messages
806
Hi - Year is typed in as 2011,2012 etc and is currently a text field in the table (not sure if thats right or wrong...)

There is a PrimaryKey in the table FinanceYearID which is an autonumber (long integer)

I tried using that instead;

Code:
DoCmd.OpenForm "frmProjectFinanceYearDetail", , , "txtFinanceYearID = '" & Me.FinanceYearID & "'"

but still no joy...
 

John Big Booty

AWF VIP
Local time
Today, 11:02
Joined
Aug 29, 2005
Messages
8,263
For that code you would need to use;
Code:
DoCmd.OpenForm "frmProjectFinanceYearDetail", , , "txtFinanceYearID =" & Me.FinanceYearID
 

andy_dyer

Registered User.
Local time
Today, 02:02
Joined
Jul 2, 2003
Messages
806
For that code you would need to use;
Code:
DoCmd.OpenForm "frmProjectFinanceYearDetail", , , "txtFinanceYearID =" & Me.FinanceYearID

Thanks I've changed to that and still get a blank form... :banghead:

Don't understand... :confused::confused:
 

John Big Booty

AWF VIP
Local time
Today, 11:02
Joined
Aug 29, 2005
Messages
8,263
Can you post a copy of your DB. '03 version for preference and certainly no newer than '07.
 

andy_dyer

Registered User.
Local time
Today, 02:02
Joined
Jul 2, 2003
Messages
806
Errmmm.... I'll need to sanitise it as it's got lots of sensitive stuff in it...

I'll do this and post it up in the next few hours... thanks for your help
 

RonnieODIN

Registered User.
Local time
Today, 03:02
Joined
Jun 15, 2012
Messages
46
I have a similar problem. I discovered that my old records actually are filtered but of some reason the record is not shown. Instead a new record is shown. I cannot figure out why it does so or how to solve it.
 

John Big Booty

AWF VIP
Local time
Today, 11:02
Joined
Aug 29, 2005
Messages
8,263
I have a similar problem. I discovered that my old records actually are filtered but of some reason the record is not shown. Instead a new record is shown. I cannot figure out why it does so or how to solve it.

Que? :confused:
 

andy_dyer

Registered User.
Local time
Today, 02:02
Joined
Jul 2, 2003
Messages
806
Sorry John - there is just no way I can remove everything to clear it of identifying info... not without re-writing it...

Is there anything else I can provide that can help you help me?
 

pr2-eugin

Super Moderator
Local time
Today, 02:02
Joined
Nov 30, 2011
Messages
8,494
Could you just put a copy of your DB? removing all sensitive information??
 

Users who are viewing this thread

Top Bottom