RE: Using a single Query as RowSource for many Combos - funny beha



In your query definition, wherever that is created, for the field in
question, use
SELECT Str(field) as NewName ...

where 'field' is the field in question and 'NewName' is a new name you give
it.

"alexhatzisavas" wrote:

>
> Hi Jim, thanks for the suggestion.
>
> How do you suggest that i define the field as an expression, im not sure i
> get this.
> In the Table Design, it's already Text.
> Also, the SQL string is constructed dynamically in VBA based on the values
> of the various controls of the Form and the chosen control.
>
>
> "Jim Burke in Novi" wrote:
>
> > Wasn't your initial concern that you're sometimes getting invalid values, as
> > opposed to how you define your rowsource? To fix that, you can define the
> > field in question as an expression that uses the Str function:
> >
> > NewFieldName: Str(FieldWithValue)
> >
> > "alexhatzisavas" wrote:
> >
> > >
> > > Hi all.
> > >
> > > I got a set of Combos on my Form, and i'm using a single Query as their
> > > RowSource.
> > > When the user clicks on a Combo, the BeforeUpdate Event is used to
> > > 'construct' the required SQL string, which is then 'passed' to the above
> > > mentioned Query with DAO (QueryDefs etc.).
> > >
> > > This works fine, i.e. the Combos are a bit faster, and display the correct
> > > set/subset of information.
> > >
> > > The problem is, sometimes they act funny.
> > >
> > > That is, when the user picks a value from the Combo list, this value is
> > > treated as Numeric (instead of Text), which creates an Error (you can't
> > > assign this value to this field etc.).
> > > The Query has the correct SQL string, and the Combo list is also ok, but the
> > > chosen value is (sometimes, not always!) recognized as Numeric (though it's
> > > Text).
> > >
> > > Here's the code i use to assign the SQL that's being constructed when the
> > > BeforeUpdate event of a Combo is fired to the Single Query that's used as the
> > > Combos' RowSouce.
> > > This code resides in the Form where the Combos are:
> > > ---------------------------------------------------------------
> > > Dim dbs as DAO.Database
> > > Dim qdf as DAO.QueryDef
> > > Dim strQrySel as String
> > >
> > > strQrySel = "Qry_ActiveSelection"
> > > Set dbs = CurrentDb()
> > > Set qdf = dbs.QueryDefs(strQrySel)
> > > qdf.SQL = strSQL ' strSQL = the SQL string that's already
> > > constructed
> > > dbs.QueryDefs.Refresh ' Refreshing the QueryDefs Collection
> > > Set qdf = Nothing
> > > Me.Requery
> > > Me.Refresh
> > > -----------------------------------------------------------------
> > > Again, this generates the correct data set for the Combos, the problem is
> > > (sometimes!) the Combos decide that this data is Numeric.
> > >
> > > Am i missing something here?
> > > Any suggestion is welcome.
> > >
> > > Thanks,
> > > Alex
> > >
> > >
> > >
.



Relevant Pages

  • Re: cant find tables used in query
    ... all of the tables in the query are hidden. ... > FROM OriginalTableName as NewName ... > INNER JOIN AnotherOriginalTable as SecondName ... > query tab of the database also. ...
    (microsoft.public.access.queries)
  • RE: Breaking down imported information
    ... Single-record append query: ... ' Check if at EOF of Recordset (rsDataViaCode) ... ' if at EOF Exit Do. ... Dim rsDataViaCode As DAO.Recordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: LDAP query information
    ... Copyright 1985-2001 Microsoft Corp. ... Dim strBase, strFilter, strAttributes, strQuery, adoRecordset ... Set adoConnection = CreateObject ... ' Construct LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)
  • Re: LDAP query information
    ... Dim strBase, strFilter, strAttributes, strQuery, adoRecordset ... Set adoConnection = CreateObject ... ' Construct LDAP syntax query. ... Yes, the script uses ADO to query AD directly, which is very efficient - no ...
    (microsoft.public.windows.server.scripting)
  • Re: Need WMI script
    ... I also assume that strGroupName is ... If instead strDomainName is the NetBIOS name of a domain, ... Dim adoCommand, adoConnection, strBase, strFilter, strAttributes, xmlDoc, ... ' Construct the LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)