dbTalk Databases Forums  

Opening a form based on two criteria displayed on another

comp.databases.ms-access comp.databases.ms-access


Discuss Opening a form based on two criteria displayed on another in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
FireyColin
 
Posts: n/a

Default Opening a form based on two criteria displayed on another - 11-16-2011 , 05:21 AM






I have a Form called 'frmPolicy' upon which are two text boxes called
respectively 'txtPolicyNo' (datatype
nvarchar) and 'txtPolicyVer' (datatype integer). I need to use these
criteria to open a new form called 'frmOtherCountryTax' with a command
button; I need to both Edit and Add information once the form is
open. The form's data source is a table named 'OtherCountryTax' with
fields named 'policy_no' and 'version_no'. I have used the wizard,
trawled help blogs and bulletin boards for hours and tried loads of
different 'solutions' all of which bring up error messages, cancel the
operation or won't allow me to edit or add the data. The latest
version is:

Dim stDocName As String
Dim stLinkCriteria As String


stDocName = "frmOtherCountryTax"
stLinkCriteria = "[policy_no]= " & Val(Me![txtPolicyNo]) & " And
[version_no]= " & Me![txtPolicyVer]


stLinkCriteria = "[policy_no]=" & Me![txtPolicyNo] & " AND
[version_no]= " & Me![txtPolicyVer]
DoCmd.OpenForm stDocName, acNormal, , , , acWindowNormal

Can anyone help before I go completely mad?

Reply With Quote
  #2  
Old   
Jon Lewis
 
Posts: n/a

Default Re: Opening a form based on two criteria displayed on another - 11-16-2011 , 06:21 AM






Try: stLinkCriteria = "[policy_no]= '" & Me![txtPolicyNo] & "' AND
[version_no]= " & Me![txtPolicyVer]

(as txtPolicyNo is text you have to enclose the value in additional
literals)

<DoCmd.OpenForm stDocName, acNormal, , , , acWindowNormal>

You haven't used strLinkCriteria in the DoCmd but I presume that is a typo,
plus if you don't specify data mode then make sure that the AllowEdits and
AllowAdditions properties of frmOtherCountryTax are set to Yes.

HTH

Jon


"FireyColin" <colin.mardell (AT) btopenworld (DOT) com> wrote

Quote:
I have a Form called 'frmPolicy' upon which are two text boxes called
respectively 'txtPolicyNo' (datatype
nvarchar) and 'txtPolicyVer' (datatype integer). I need to use these
criteria to open a new form called 'frmOtherCountryTax' with a command
button; I need to both Edit and Add information once the form is
open. The form's data source is a table named 'OtherCountryTax' with
fields named 'policy_no' and 'version_no'. I have used the wizard,
trawled help blogs and bulletin boards for hours and tried loads of
different 'solutions' all of which bring up error messages, cancel the
operation or won't allow me to edit or add the data. The latest
version is:

Dim stDocName As String
Dim stLinkCriteria As String


stDocName = "frmOtherCountryTax"
stLinkCriteria = "[policy_no]= " & Val(Me![txtPolicyNo]) & " And
[version_no]= " & Me![txtPolicyVer]


stLinkCriteria = "[policy_no]=" & Me![txtPolicyNo] & " AND
[version_no]= " & Me![txtPolicyVer]
DoCmd.OpenForm stDocName, acNormal, , , , acWindowNormal

Can anyone help before I go completely mad?

Reply With Quote
  #3  
Old   
FireyColin
 
Posts: n/a

Default Re: Opening a form based on two criteria displayed on another - 11-16-2011 , 06:31 AM



On Nov 16, 12:21*pm, "Jon Lewis" <jon.le... (AT) cutthespambtinternet (DOT) com>
wrote:
Quote:
Try: * *stLinkCriteria = "[policy_no]= '" & Me![txtPolicyNo] & "'AND
[version_no]= " & Me![txtPolicyVer]

(as txtPolicyNo is text you have to enclose the value in additional
literals)

DoCmd.OpenForm stDocName, acNormal, , , , acWindowNormal

You haven't used strLinkCriteria in the DoCmd but I presume that is a typo,
plus if you don't specify data mode then make sure that the AllowEdits and
AllowAdditions properties of frmOtherCountryTax are set to Yes.

HTH

Jon

"FireyColin" <colin.mard... (AT) btopenworld (DOT) com> wrote in message

news:3f366c1a-d9c2-4cb7-a5eb-79b8126fc2e0 (AT) o14g2000yqh (DOT) googlegroups.com...



I have a Form called 'frmPolicy' upon which are two text boxes called
respectively 'txtPolicyNo' (datatype
nvarchar) and 'txtPolicyVer' (datatype integer). *I need to use these
criteria to open a new form called 'frmOtherCountryTax' with a command
button; I need to both Edit and Add information once the form is
open. *The form's data source is a table named 'OtherCountryTax' with
fields named 'policy_no' and 'version_no'. *I have used the wizard,
trawled help blogs and bulletin boards for hours and tried loads of
different 'solutions' all of which bring up error messages, cancel the
operation or won't allow me to edit or add the data. The latest
version is:

* *Dim stDocName As String
* *Dim stLinkCriteria As String

* *stDocName = "frmOtherCountryTax"
* *stLinkCriteria = "[policy_no]= " & Val(Me![txtPolicyNo]) & "And
[version_no]= " & Me![txtPolicyVer]

* *stLinkCriteria = "[policy_no]=" & Me![txtPolicyNo] & " AND
[version_no]= " & Me![txtPolicyVer]
* *DoCmd.OpenForm stDocName, acNormal, , , , acWindowNormal

Can anyone help before I go completely mad?- Hide quoted text -

- Show quoted text -
Thanks John

I tried that it just comes up "Compile Error: Expected end of
statement"

Colin

Reply With Quote
  #4  
Old   
Jon Lewis
 
Posts: n/a

Default Re: Opening a form based on two criteria displayed on another - 11-16-2011 , 06:45 AM



Dim stLinkCriteria As String
stLinkCriteria = "[policy_no]= '" & Me![txtPolicyNo] & "' AND [version_no]=
" & Me![txtPolicyVer]

Compiles Ok for me or are you talking about another code line?

Jon


"FireyColin" <colin.mardell (AT) btopenworld (DOT) com> wrote

On Nov 16, 12:21 pm, "Jon Lewis" <jon.le... (AT) cutthespambtinternet (DOT) com>
wrote:
Quote:
Try: stLinkCriteria = "[policy_no]= '" & Me![txtPolicyNo] & "' AND
[version_no]= " & Me![txtPolicyVer]

(as txtPolicyNo is text you have to enclose the value in additional
literals)

DoCmd.OpenForm stDocName, acNormal, , , , acWindowNormal

You haven't used strLinkCriteria in the DoCmd but I presume that is a
typo,
plus if you don't specify data mode then make sure that the AllowEdits and
AllowAdditions properties of frmOtherCountryTax are set to Yes.

HTH

Jon

"FireyColin" <colin.mard... (AT) btopenworld (DOT) com> wrote in message

news:3f366c1a-d9c2-4cb7-a5eb-79b8126fc2e0 (AT) o14g2000yqh (DOT) googlegroups.com...



I have a Form called 'frmPolicy' upon which are two text boxes called
respectively 'txtPolicyNo' (datatype
nvarchar) and 'txtPolicyVer' (datatype integer). I need to use these
criteria to open a new form called 'frmOtherCountryTax' with a command
button; I need to both Edit and Add information once the form is
open. The form's data source is a table named 'OtherCountryTax' with
fields named 'policy_no' and 'version_no'. I have used the wizard,
trawled help blogs and bulletin boards for hours and tried loads of
different 'solutions' all of which bring up error messages, cancel the
operation or won't allow me to edit or add the data. The latest
version is:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmOtherCountryTax"
stLinkCriteria = "[policy_no]= " & Val(Me![txtPolicyNo]) & " And
[version_no]= " & Me![txtPolicyVer]

stLinkCriteria = "[policy_no]=" & Me![txtPolicyNo] & " AND
[version_no]= " & Me![txtPolicyVer]
DoCmd.OpenForm stDocName, acNormal, , , , acWindowNormal

Can anyone help before I go completely mad?- Hide quoted text -

- Show quoted text -
Thanks John

I tried that it just comes up "Compile Error: Expected end of
statement"

Colin

Reply With Quote
  #5  
Old   
FireyColin
 
Posts: n/a

Default Re: Opening a form based on two criteria displayed on another - 11-16-2011 , 08:50 AM



On Nov 16, 11:21*am, FireyColin <colin.mard... (AT) btopenworld (DOT) com> wrote:
Quote:
I have a Form called 'frmPolicy' upon which are two text boxes called
respectively 'txtPolicyNo' (datatype
nvarchar) and 'txtPolicyVer' (datatype integer). *I need to use these
criteria to open a new form called 'frmOtherCountryTax' with a command
button; I need to both Edit and Add information once the form is
open. *The form's data source is a table named 'OtherCountryTax' with
fields named 'policy_no' and 'version_no'. *I have used the wizard,
trawled help blogs and bulletin boards for hours and tried loads of
different 'solutions' all of which bring up error messages, cancel the
operation or won't allow me to edit or add the data. The latest
version is:

* * Dim stDocName As String
* * Dim stLinkCriteria As String

* * stDocName = "frmOtherCountryTax"
* * stLinkCriteria = "[policy_no]= " & Val(Me![txtPolicyNo]) & " And
[version_no]= " & Me![txtPolicyVer]

* * stLinkCriteria = "[policy_no]=" & Me![txtPolicyNo] & " AND
[version_no]= " & Me![txtPolicyVer]
* * DoCmd.OpenForm stDocName, acNormal, , , , acWindowNormal

Can anyone help before I go completely mad?
Many Thanks Jon all okay now with:

stLinkCriteria = "[policy_no]= '" & Me![txtPolicyNo] & "' AND
[version_no]= " & Me![txtPolicyVer]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.