RE: Using a single Query as RowSource for many Combos - funny beha
- From: "Jim Burke in Novi" <JimBurkeinNovi@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 3 Dec 2005 09:03:02 -0800
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
> > >
> > >
> > >
.
- Prev by Date: Re: Save User Information
- Next by Date: Re: Access SQL DAYOFWEEK() problem
- Previous by thread: Save User Information
- Next by thread: Re: Export menubar
- Index(es):
Relevant Pages
|