K
Kahuna
Hi Folks
Following on from last nights disaster <lol> (Doug, John and Bas know what I
mean) - I need some guidance on this one:
I have an SQL Update statement (that works!!), which takes an input from a
form to show which field to update in the table, a second input from the
form which says update where 'x' is the current table entry, and a third
input where the user types in what he'd like the data changed to.
All works lovely in a text field in the table but fails dismally when there
is a number / bool / date etc.
I know the data type number of the field chosen to be updated, but cant find
the way to set the SQL variables to assume the data types of the field.
Here's the SQL string:
strSQLUpdate = "UPDATE qryFabricCondition SET qryFabricCondition." &
[txtField_to_Update] & " = " & "'" & txtUpdate_With & "'" & "" _
& " WHERE (qryFabricCondition." &
[txtField_to_Update] & "= " & "'" & txt_Where_equal_to & "'" & ")"
The variable txtUpdate_With is actually now Dim'd as a variant, thought this
would allow it to assume the data type of the field to update to.
Guess: Is it possible to set the form field to accept only a
particular data type?
Is it possible to set the variable to a specific data type
before adding it to the SQL statement?
I need to remove the extra quotes around the
txtUpdate_With variable dependant upon the data type -
This last seems most likely - but does that mean
building the SQL on the fly or creating multiple copies of it (one for each
type)?
Help appreciated.
TIA
Following on from last nights disaster <lol> (Doug, John and Bas know what I
mean) - I need some guidance on this one:
I have an SQL Update statement (that works!!), which takes an input from a
form to show which field to update in the table, a second input from the
form which says update where 'x' is the current table entry, and a third
input where the user types in what he'd like the data changed to.
All works lovely in a text field in the table but fails dismally when there
is a number / bool / date etc.
I know the data type number of the field chosen to be updated, but cant find
the way to set the SQL variables to assume the data types of the field.
Here's the SQL string:
strSQLUpdate = "UPDATE qryFabricCondition SET qryFabricCondition." &
[txtField_to_Update] & " = " & "'" & txtUpdate_With & "'" & "" _
& " WHERE (qryFabricCondition." &
[txtField_to_Update] & "= " & "'" & txt_Where_equal_to & "'" & ")"
The variable txtUpdate_With is actually now Dim'd as a variant, thought this
would allow it to assume the data type of the field to update to.
Guess: Is it possible to set the form field to accept only a
particular data type?
Is it possible to set the variable to a specific data type
before adding it to the SQL statement?
I need to remove the extra quotes around the
txtUpdate_With variable dependant upon the data type -
This last seems most likely - but does that mean
building the SQL on the fly or creating multiple copies of it (one for each
type)?
Help appreciated.
TIA