try:
strSQL = "UPDATE EVMASTER SET EVMASTER.OWNLAST = " & me.LASTNAME & " WHERE
EVMASTER.PRACHECKBOX = True;"
this assumes 'Lastname" is name of the textbox in your form footer (could
cause issues if you have a field with same name)
note the inclusion of space before the Where clause - " Where......"
note also that me.lastname must be updated (press ENTER) for it to truly
contain the value
if that fails - i always check syntax by actually setting up the query
(substitue me.lastname with any word) - check it works (updates correctly) -
switch to SQL view and copy/paste the sql code directly - replace the 'word'
with : & me.LASTNAME &
| I'm getting closer! I narrowed down the cause of the error. Using the
| following code:
| -----------Code Start------------
| Private Sub testbutton_Click()
| Me.Refresh
| strSQL = "UPDATE EVMASTER SET EVMASTER.OWNLAST =
| 'FORMS!PRACHECKLIST!LASTNAME'" & " WHERE EVMASTER.PRACHECKBOX = True;"
| DBEngine(0)(0).Execute strSQL, dbFailOnError
| Me.Refresh
| End Sub
| -----------Code End-------------
|
| I added single quotes around the LASTNAME control to see if the basic
| function would work and it did - of course it enters the text
| "FORMS!PRACHECKLIST!LASTNAME" in the appropriate fields instead of the
value.
| When I remove the single quotes to try to put the value in the fields, I
get
| the error. Therefore, the error must be in the syntax of the LASTNAME
| control value. This value comes from an unbound control [LASTNAME] on the
| form [PRACHECKLIST] where all of this is being done. What would the
syntax
| be for this?
| --
| I'm not young enough to know everything.
|
|
| "JethroUK©" wrote:
|
| > CurrentDb.Execute "UPDATE mytable SET myfield = " & mytextbox & "WHERE
| > mycheckfield = Yes"
| >
| >
| > | > | i would say the best method is to get them to add their name first,
then
| > | update the field using checkbox after update
| > |
| > | sub checkbox_afterupdate
| > | myfield = mytextbox
| > | end sub
| > |
| > | if it's crucial they add their name afterwards then the best method is
to
| > | run an Update query where mycheckbox = True
| > |
| > |
| > |
| > |
| > | | > | | I don't believe you understand what I am looking for. I don't have
a
| > | problem
| > | | printing the records. I want to take the information entered into
the
| > | | unbound control "LASTNAME" and place it into the field "OWN_LAST"
for
| > | every
| > | | record where "PRACHECKBOX" equals "TRUE". I was trying to place
this
| > | action
| > | | into the OnClick event of the Command Button that prints a report.
| > | | --
| > | | I'm not young enough to know everything.
| > | |
| > | |
| > | | "JethroUK©" wrote:
| > | |
| > | | > easiest way is to use the form filter
| > | | >
| > | | > Filter = 'mycheckbox = yes'
| > | | > Filteron = true
| > | | >
| > | | > print my records
| > | | >
| > | | > filteron = false
| > | | >
| > | | >
| > | | > | > | | > | WindowsXP Pro, Access 2003, familiar with VBA.
| > | | > |
| > | | > | I have a continuous form with fields based on a query
"PRACHECKLIST"
| > | which
| > | | > | is based on a table "EVMASTER". Some of the fields are for
owner
| > | | > information
| > | | > | - "LASTNAME", "FIRSTNAME", etc. There is also a checkbox named
| > | | > | "PRACHECKBOX". All of this is in the detail section of the
form.
| > The
| > | | > | purpose of this form is to allow the user to select specific
records
| > | using
| > | | > | the checkbox. They then enter the owner information into
unbound
| > text
| > | | > boxes
| > | | > | in the form footer. This information is then passed to a report
| > "PRA"
| > | | > which
| > | | > | prints all records and the owner information which we have the
owner
| > | sign
| > | | > | when they pick up the selected items.
| > | | > |
| > | | > | What I am trying to do is to pass the owner information from the
| > | unbound
| > | | > | text boxes to the corresponding owner information fields for
records
| > | where
| > | | > | the checkbox = true when the form is printed. The form is
printed
| > | using a
| > | | > | command button with an onclick event.
| > | | > | --
| > | | > | I'm not young enough to know everything.
| > | | >
| > | | >
| > | | >
| > |
| > |
| >
| >
| >