Form Coding Problem for New Rec 
Author Message
 Form Coding Problem for New Rec

Here is the code that works fine in my database as on click
property:
Private Sub addstubutton_Click()
On Error GoTo Err_addstubutton_Click
Const cQuote = """"
    Me!classid.DefaultValue = cQuote & Me!classid.Value & cQuote
    Me!cnum.DefaultValue = cQuote & Me!cnum.Value & cQuote
    Me!dt1.DefaultValue = cQuote & Me!dt1.Value & cQuote
    Me!dt2.DefaultValue = cQuote & Me!dt2.Value & cQuote
    DoCmd.GoToRecord , , acNewRec
    Me!EmpID.SetFocus
(i left off the error part)
This works fine to allow me to add a new record and it keeps the
values I want in the specified fields.
I have another button, following this format that is to keep
information in three other fields while leaving those fields
blank when it goes to the newrec. I also have another button that
should just take me to a an undirtied newrec.
What i get when i click on either button is that it keeps the
fields listed in above code, does not allow me to edit unless I
save the record first.
Here is the bad (puts code in corner) code:
On Error GoTo Err_addclassbutton_Click

    Const cQuote = """"
    Me!EmpID.DefaultValue = cQuote & Me!EmpID.Value & cQuote
    Me!lname.DefaultValue = cQuote & Me!lname.Value & cQuote
    Me!fname.DefaultValue = cQuote & Me!fname.Value & cQuote
    DoCmd.GoToRecord , , acNewRec
    Me!classid.SetFocus

and:
On Error GoTo Err_addnewclass_Click

    DoCmd.GoToRecord , , acNewRec
    Me.classid.SetFocus
The source for the form is a query comprised of two tables and
one query (which is used for pulling in a couple of pieces of
information): Employees Table, Attendance Table (joined to
employees table so that an employee can show up numerous times),
OtherQuery (joined to attendance table on class number so that it
brings in the courseid, class name, beginning and ending dates of
class. class number in att. table is joined to the primary key in
another table which is where this table is joined to the query).

What changes do i need to make so this will function as i intend?
TIA

IntheMyst

* Sent from RemarQ http://www.*-*-*.com/ The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



Sat, 30 Nov 2002 03:00:00 GMT  
 Form Coding Problem for New Rec
You should Refresh the current form before going to new record, insert:
    Me.Refresh
before DoCmd

Code Luck!

Quote:
> Here is the code that works fine in my database as on click
> property:
> Private Sub addstubutton_Click()
> On Error GoTo Err_addstubutton_Click
> Const cQuote = """"
>     Me!classid.DefaultValue = cQuote & Me!classid.Value & cQuote
>     Me!cnum.DefaultValue = cQuote & Me!cnum.Value & cQuote
>     Me!dt1.DefaultValue = cQuote & Me!dt1.Value & cQuote
>     Me!dt2.DefaultValue = cQuote & Me!dt2.Value & cQuote
>     DoCmd.GoToRecord , , acNewRec
>     Me!EmpID.SetFocus
> (i left off the error part)
> This works fine to allow me to add a new record and it keeps the
> values I want in the specified fields.
> I have another button, following this format that is to keep
> information in three other fields while leaving those fields
> blank when it goes to the newrec. I also have another button that
> should just take me to a an undirtied newrec.
> What i get when i click on either button is that it keeps the
> fields listed in above code, does not allow me to edit unless I
> save the record first.
> Here is the bad (puts code in corner) code:
> On Error GoTo Err_addclassbutton_Click

>     Const cQuote = """"
>     Me!EmpID.DefaultValue = cQuote & Me!EmpID.Value & cQuote
>     Me!lname.DefaultValue = cQuote & Me!lname.Value & cQuote
>     Me!fname.DefaultValue = cQuote & Me!fname.Value & cQuote
>     DoCmd.GoToRecord , , acNewRec
>     Me!classid.SetFocus

> and:
> On Error GoTo Err_addnewclass_Click

>     DoCmd.GoToRecord , , acNewRec
>     Me.classid.SetFocus
> The source for the form is a query comprised of two tables and
> one query (which is used for pulling in a couple of pieces of
> information): Employees Table, Attendance Table (joined to
> employees table so that an employee can show up numerous times),
> OtherQuery (joined to attendance table on class number so that it
> brings in the courseid, class name, beginning and ending dates of
> class. class number in att. table is joined to the primary key in
> another table which is where this table is joined to the query).

> What changes do i need to make so this will function as i intend?
> TIA

> IntheMyst

> * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network
*
> The fastest and easiest way to search and participate in Usenet - Free!



Sun, 01 Dec 2002 03:00:00 GMT  
 Form Coding Problem for New Rec
I have one button working right but the one that is misbehaving
is the one that is to go to a new record. I have the refresh line
in there yet it does not do what it should. When I click on this
button, it keeps the information on classes and won't let me
change anything without saving it first.
here is the code on it:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
DoCmd.GoToRecord , , acNewRec
    Me.classid.SetFocus
    Me.refresh
I even tried putting the refresh command before docmd and it
keeps giving me this same error. Any ideas why and any ideas as
to how can remedy this?

IntheMyst

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



Sat, 14 Dec 2002 03:00:00 GMT  
 Form Coding Problem for New Rec

Quote:

>I have one button working right but the one that is misbehaving
>is the one that is to go to a new record. I have the refresh line
>in there yet it does not do what it should. When I click on this
>button, it keeps the information on classes and won't let me
>change anything without saving it first.
>here is the code on it:
>DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
>acMenuVer70
>DoCmd.GoToRecord , , acNewRec
>    Me.classid.SetFocus
>    Me.refresh
>I even tried putting the refresh command before docmd and it
>keeps giving me this same error. Any ideas why and any ideas as
>to how can remedy this?

>IntheMyst

Shouldn't doing a refresh save the record anyhow (or moving to a new record
even)? I think your problem is in why it requires you to save the record...
should not be the case... but cannot tell from the info you gave why.

Me.Refresh
Docmd.GotoRecord, Me.Formname, acNewRec
Me![classid].SetFocus

(Good habit to use correct syntax.. "dots" are used for properties and
methods of an object, not field names :)
--
regards,

A Christian Response
(to martial arts, meditation, yoga, reiki, and more)
  http://www.pastornet.net.au/response/



Sun, 15 Dec 2002 03:00:00 GMT  
 Form Coding Problem for New Rec
Please see code in above message.
I have noticed that I only get this error when i want to go to a
completely new record after having entered a record in which
pressing a button with code that contains const in it is used.
How to I take care of this issue so that this does not happen?

IntheMyst

-----------------------------------------------------------

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



Mon, 16 Dec 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Problem with adding new rec with form containing a subform

2. New Rec with previous Rec data

3. Perform a go to new rec w/ retaining some info from prev rec

4. Move to newrecord adds rec to db, but cant move to new rec

5. New Rec with previous Rec data

6. New Rec with Data Based on Previous Rec's Data

7. Subform retains data when going to new rec via coded rtn

8. New record added to listbox, but won't load rec in form when selec

9. Stop new rec on form from stopping refresh of linked tables

10. Insert new rec, then pass new identity val back to Access97


 
Powered by phpBB® Forum Software © phpBB Group