Jumat, 11 Mei 2012

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

Hi John,

but that is not the case. I.e. the combo box is bound only to one column, and that is the very column called (Mässor Huvudtitel] containing the name of the Trade Fair.
So I tried a "quick-and-dirty" idea: I added a new control box to the form with the column [Mässor Huvudtitel] in the table Mässor as datasource and then used that one in the link criteria in my VBA code. But I still got just an empty form opened. Could it be that the field I use in my link criteria must also be a column in the table? I.e. is it not enough if it is a control box on the form?

Kindly regards
Dennis Davidsson

11 maj 2012 kl. 14:51 skrev John Viescas:

> Dennis-
>
> Probably. You have to filter the bound value of the combo box, which is not
> necessarily what is displayed. For example, if it is bound to and ID field but
> displays a name, you have to filter for the ID value.
>
> John Viescas, author
> Microsoft Office Access 2010 Inside Out
> Microsoft Office Access 2007 Inside Out
> Building Microsoft Access Applications
> Microsoft Office Access 2003 Inside Out
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
> -----Original Message-----
> From: MS_Access_Professionals@yahoogroups.com
> [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Dennis Davidsson
> Sent: Friday, May 11, 2012 2:32 PM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: Re: [MS_AccessPros] To open a from with link criteria from a subform
>
> Thanks Graham and John for your suggested solution to my problem!
> It solved my syntax problem correctly.
> However, then coming one step further in my debugging I immediately ran into the
> next problem:
> I got my form Mässor opened ok. Fine so far.
> But, instead of, as I had expected, getting the form opened filtered by the
> name of the Trade Fair 'BRAU Beviale' , I just got the form opened with the
> combo box called (Mässa Huvudtitel] (and all other controls on the form as
> well) empty!
> I have checked in the tables that I should get a match on the used value, so the
> problem is not as simple as that.
> So my question is: Do I have to modify my sentence stLinkCriteria in some way,
> because it is a combo box rather than an ordinary control box?
>
> Kindly regards
> Dennis Davidsson
>
> 11 maj 2012 kl. 12:48 skrev John Viescas:
>
> > Dennis-
> >
> > You must enclose the criteria string in quotes. Try this:
> >
> > stLinkCriteria = "[Mässa Huvudtitel]=""" & _
> > [Forms]![Adressregister]![Kontaktpersoner]![BranschKP3].[Form]![Bransch] &
> > """"
> >
> > John Viescas, author
> > Microsoft Office Access 2010 Inside Out
> > Microsoft Office Access 2007 Inside Out
> > Building Microsoft Access Applications
> > Microsoft Office Access 2003 Inside Out
> > SQL Queries for Mere Mortals
> > http://www.viescas.com/
> > (Paris, France)
> >
> > --------------
> >
> > From: MS_Access_Professionals@yahoogroups.com
> > [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Dennis Davidsson
> > Sent: Friday, May 11, 2012 12:20 PM
> > 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
> >
> > [Non-text portions of this message have been removed]
> >
> >
>
> [Non-text portions of this message have been removed]
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>



[Non-text portions of this message have been removed]



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/MS_Access_Professionals/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/MS_Access_Professionals/join
(Yahoo! ID required)

<*> To change settings via email:
MS_Access_Professionals-digest@yahoogroups.com
MS_Access_Professionals-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
MS_Access_Professionals-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

Tidak ada komentar:

Posting Komentar