Re: what is wrong with this code?
From: Dirk Goldgar (dg_at_NOdataSPAMgnostics.com)
Date: 09/03/04
- Next message: Frank Stone: "printing a blank form in access"
- Previous message: Allen Browne: "Re: Creating a new form"
- In reply to: hermie: "what is wrong with this code?"
- Next in thread: hermie: "Re: what is wrong with this code?"
- Reply: hermie: "Re: what is wrong with this code?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 3 Sep 2004 12:09:25 -0400
"hermie" <hermie@coqui.net> wrote in message
news:9tZZc.343$tT5.126@fe61.usenetserver.com
> In the field [ss] on my data entry form I put code in the afterUpdate
> field. The code runs but not update the field in table notas. First
> I get the message: You are about to run an append query that will
> modify data in your table. when I click OK a second message appears
> which says: You are about to append 0 row(s) What should be 1 row
>
> What is wrong with the code?
>
> Private Sub ss_AfterUpdate()
> DoCmd.OpenQuery ("Students_Without_Matching_Notas")
> Run
> DoCmd.Close ("Students_Without_Matching_Notas")
> DoCmd.OpenQuery ("addssnota")
> End Sub
>
> any help is welcome
>
> Herman
1. I don't understand what is the purpose of the line
> Run
As far as I can tell, it isn't going to do anything.
2. This line:
> DoCmd.Close ("Students_Without_Matching_Notas")
should fail, since it doesn't conform to the correct syntax for the
DoCmd.Close method. Have you got "On Error Resume Next" in force
somehow?
3. Does your append query, "addssnota", rely on the value of [ss] being
stored in a table already? If so, that won't have happened yet in the
AfterUpdate event of that control, because the current record won't have
been saved yet. You can force the record to be saved by executing the
line
RunCommand acCmdSaveRecord
before executing the append query -- presuming that all required fields
have been completed and the record is valid. Or you could run your code
in the *form's* AfterUpdate or AfterInsert event instead.
-- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup)
- Next message: Frank Stone: "printing a blank form in access"
- Previous message: Allen Browne: "Re: Creating a new form"
- In reply to: hermie: "what is wrong with this code?"
- Next in thread: hermie: "Re: what is wrong with this code?"
- Reply: hermie: "Re: what is wrong with this code?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|