Re: Whats wrong with this code?? A97 XP SP2
- From: "Dan Artuso" <dartuso@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 5 Apr 2005 13:03:59 -0400
Hi,
This section:
strSQL_to_run = "UPDATE qryFabricCondition SET
qryFabricCondition.fc_ccr_value = [str_ccr_to_apply]" _
& " WHERE (((qryFabricCondition.lb_label_1)= [str_field_to_apply]))"
You always have to evaluate and concatenate the variable in all versions of Access:
strSQL_to_run = "UPDATE qryFabricCondition SET qryFabricCondition.fc_ccr_value = '" & str_ccr_to_apply] & "'" & _
" WHERE (((qryFabricCondition.lb_label_1)= '" & str_field_to_apply & "'))"
You should be issuing a Debug.Print on *all* of your sql statements so you can easily see where the errors are.
--
HTH
-------
Dan Artuso, MVP
"Kahuna" <none@xxxxxxxxxxxx> wrote in message news:OpJugAgOFHA.3376@xxxxxxxxxxxxxxxxxxxxxxx
> Hi Folks - been round the houses with this code before I am sure, but once
> again have a query in code that seems to think there are parameters to
> fulfil!
>
> Here's the code:
>
> 'Loop through all Library data
> Do While Not rs_LibraryData.EOF
> If rs_LibraryData![ccr_use_serv_cd] = True Then ' If
> Service Code is to be used
> str_field_to_apply = "lb_label_1"
> '****************************************
> str_ccr_to_apply = rs_LibraryData![ccr_ccr]
> If rs_LibraryData![ccr_like] = True Then ' If the
> routine should use Like (for wildcards)
> strSQL_to_run = "UPDATE qryFabricCondition SET
> qryFabricCondition.fc_ccr_value = [str_ccr_to_apply]" _
> & " WHERE (((qryFabricCondition.lb_label_1)=
> Like & [str_field_to_apply] & " * "))"
> Else ' If Not
> Like
> strSQL_to_run = "UPDATE qryFabricCondition SET
> qryFabricCondition.fc_ccr_value = [str_ccr_to_apply]" _
> & " WHERE (((qryFabricCondition.lb_label_1)=
> [str_field_to_apply]))"
> End If
> '****************************************
> Else ' If
> Component to be used instead
> 'str_field_to_apply = "fc_main1"
> '****************************************
> 'If rs_LibraryData![ccr_like] = True Then ' If the
> routine should use Like (for wildcards)
> 'strSQL_to_run = ""
> 'Else ' If Not
> Like
> 'strSQL_to_run = ""
> 'End If
> '****************************************
> End If
> MsgBox strSQL_to_run
> DoCmd.RunSQL (strSQL_to_run)
>
> If rs_LibraryData.EOF Then Exit Do
> Loop
> Just working on the first part of the If - Loop for now.
>
> ************************************************************************************
> strSQL_to_run = "UPDATE qryFabricCondition SET
> qryFabricCondition.fc_ccr_value = [str_ccr_to_apply]" _
> & " WHERE (((qryFabricCondition.lb_label_1)=
> [str_field_to_apply]))"
> ************************************************************************************
>
> This section is the first piece of offending code - and raises a parameter
> input box. even though the variables have the correct information in them. I
> seem to recall that A97 will not define the parameters in code and needs
> some extra input to define the parameters.
>
> Any help on what and where to input this code would be appreciated.
>
> Cheers
> --
> Kahuna
> ------------
>
>
.
- Follow-Ups:
- Re: Whats wrong with this code?? A97 XP SP2
- From: Kahuna
- Re: Whats wrong with this code?? A97 XP SP2
- References:
- Whats wrong with this code?? A97 XP SP2
- From: Kahuna
- Whats wrong with this code?? A97 XP SP2
- Prev by Date: Waiting for Powerpoint to finish
- Next by Date: How to add new records in Access using VBA code?
- Previous by thread: Re: Whats wrong with this code?? A97 XP SP2
- Next by thread: Re: Whats wrong with this code?? A97 XP SP2
- Index(es):
Relevant Pages
|