Jumat, 11 Mei 2012

RE: [MS_AccessPros] To open a from with link criteria from a subform

 

Hello Dennis

Because [Mässa Huvudtitel] is a text field, you must enclose 'BRAU Beviale'
in either single or double quotes. These quotes need to be included in the
expression which is assigned to stLinkCriteria:

stLinkCriteria = "[Mässa Huvudtitel]='" &
[Forms]![Adressregister]![Kontaktpersoner]![BranschKP3].[Form]![Bransch] &
"'"

Also, if your [Mässor] command button is on the form [Adressregister] then
you do not need to fully qualify the reference to the textbox:

stLinkCriteria = "[Mässa Huvudtitel]='" &
Me![Kontaktpersoner]![BranschKP3].[Form]![Bransch] & "'"

If the command button is on your [BranschKP3] subform, then you can simplify
it even further:

stLinkCriteria = "[Mässa Huvudtitel]='" & Me![Bransch] & "'"

Best wishes,
Graham

> From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Dennis
Davidsson
> Sent: Friday, 11 May 2012 22:20
> To: MS_Access_Professionals@yahoogroups.com
> Subject: [MS_AccessPros] To open a from with link criteria from a subform
>
>  
>
> Hello,
>
> Trying to open another form from my primary form by clicking a button I
get the following error message from Access , which I cannot figure out how
to correct:
>
> Syntax error(operator missing) in the query expression '[Mässa
Huvudtitel]=BRAU Beviale'
>
> The character string value 'BRAU Beviale' is the name of a Trade Fair and
it is correctly obtained from the reference to a value in a combo box in a
subform of a subform in the piece of code below.
>
> What is wrong with my piece of VBA code behind the button?
> The code is as follows:
>
> Private Sub Mässor_Click()
> On Error GoTo Err_Mässor_Click
>
> Dim stDocName As String
> Dim stLinkCriteria As String
>
> stDocName = "Mässor"
> stLinkCriteria = "[Mässa Huvudtitel]=" &
[Forms]![Adressregister]![Kontaktpersoner]![BranschKP3].[Form]![Bransch]
> DoCmd.OpenForm stDocName, , , stLinkCriteria
>
> Exit_Mässor_Click:
> Exit Sub
>
> Err_Mässor_Click:
> MsgBox Err.Description
> Resume Exit_Mässor_Click
>
> End Sub
>
> Kindly regards
> Dennis Davidsson

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar