Re: Match fields with VBA
- From: "Sean" <Sean@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 9 Aug 2005 14:33:14 -0700
I went a little different route, using a filter on recordset. However, I
can't seem to pass the variable into the mix.
This works.
Set rsttasks = db.OpenRecordset("SELECT * " & _
"FROM [MSP_Tasks] WHERE [TASK_UID] = 2")
But then I replace the 2 with a variable and it bombs
Dim var As Integer
var = 2
Set rsttasks = db.OpenRecordset("SELECT * " & _
"FROM [MSP_Tasks] WHERE [TASK_UID] = var")
I've also tried it with var defined as a string.
Thoughts? Thank you
"Tim Ferguson" wrote:
> "=?Utf-8?B?U2Vhbg==?=" <Sean@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
> news:ED861955-7CD3-41EF-A252-30A61B02E2F7@xxxxxxxxxxxxx:
>
> > strname = Select TASK_NAME " & _
> > "from MSP_TASKS " & _
> > "where MSP_TASKS!TASK_ID = MSP_LINKS!LINK_PRED_ID"
>
>
> A couple of problems:
>
> a) SQL does not have a bang! operator. You access columns of a table
> using a dot operator only: Msp_Tasks.TaskID
>
> b) Msp_Links.Link_Pred_ID is not a single value -- it's a whole column of
> values. Therefore this particular constraint is not meaningful even if it
> were grammatic.
>
> You can indeed create SQL commands in VBA -- in fact it's normal
> procedure -- but there are two things to do first:
>
> (a) make sure you know what you are trying to achieve ("pulling a value
> from a table" does not make sense without _much_ more information), and
>
> (b) get the SQL debugged first. The easiest way to do this is to use the
> query designer in Access itself: then either switch to SQL view to copy
> the code into your vba editor; or just save the thing as a querydef and
> base your recordset on that.
>
> Hope that helps
>
>
>
> Tim F
>
>
.
- Follow-Ups:
- Re: Match fields with VBA
- From: Tim Ferguson
- Re: Match fields with VBA - Solved it
- From: Sean
- Re: Match fields with VBA
- References:
- Match fields with VBA
- From: Sean
- Re: Match fields with VBA
- From: Tim Ferguson
- Match fields with VBA
- Prev by Date: Filling in a grid of text boxes using nested loops?
- Next by Date: Re: MCDBA
- Previous by thread: Re: Match fields with VBA
- Next by thread: Re: Match fields with VBA - Solved it
- Index(es):
Relevant Pages
|