Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: New record by clicking the NEXT button


Message #1 by "Enzo Zaragoza" <enzaux@g...> on Fri, 18 Jan 2002 22:51:27 +0800

This is a multi-part message in MIME format.



------=_NextPart_000_00F1_01C1A072.A97900C0

Content-Type: text/plain;

	charset="iso-8859-1"

Content-Transfer-Encoding: quoted-printable



Hello!!!



   Hi!!!  I made a set of buttons similar to the Record Navigation of 

the form.  I was just wondering on how I could disabling the next button 

to make a new record if its in the last record of the table.  What I did 

is went to Form properties and set "Allow Additions" to No, now the 

probLem is with this setting I could not even add a new record even I 

used the add button.  Any idea?  Thanks!!!



Enzo :)






Message #2 by Lonnie Johnson <prodevmg@y...> on Fri, 18 Jan 2002 06:54:56 -0800 (PST)
--0-845077306-1011365696=:41409

Content-Type: text/plain; charset=us-ascii





In your Add Button's On Click procedure, put code set the Allow Additions property to Yes.  



Me.AllowAdditions = True



Then in the Form's After Update Event set it back to False.

Hope this helps ya.

 

  Enzo Zaragoza <enzaux@g...> wrote: Hello!!!    Hi!!!  I made a set of buttons similar to the Record Navigation of the
form.  I was just wondering on how I could disabling the next button to make a new record if its in the last record of the table. 
What I did is went to Form properties and set "Allow Additions" to No, now the probLem is with this setting I could not even add a
new record even I used the add button.  Any idea?  Thanks!!! Enzo :)---





Lonnie Johnson ljprodev@y... 

ProDev, Builders of MS Access Databases

Let ProDev build your next MS Access database application. 

http://www.galaxymall.com/software/PRODEV 



Get paid cash every time you receive email!

Sign up FREE at: http://www.MintMail.com/?m=975303





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

Do You Yahoo!?

Send FREE video emails in Yahoo! Mail.


Message #3 by "Gregory Serrano" <SerranoG@m...> on Fri, 18 Jan 2002 16:43:12
Enzo,



<< Hi!!!  I made a set of buttons similar to the Record Navigation of the 

form.  I was just wondering on how I could disabling the next button to 

make a new record if its in the last record of the table. >>



It sounds like you want to be able to add records to your table with 

an "Add Record" button but not by scrolling using "Previous" / "Next" 

buttons.  When you get to the end of the records, you want your "Next 

Record" button to disable so that they cannot "fall off the end" and enter 

a new record that way... so to speak.



Try this in the form's "On Current" event:



    Dim MyDB As Database, MyTable As Recordset

    Dim FirstRec As String, LastRec As String

                

    Set MyDB = DBEngine.Workspaces(0).Databases(0)

    Set MyTable = MyDB.OpenRecordset("TableInQuestion", DB_OPEN_DYNASET)

    

    MyTable.MoveFirst

    FirstRec = MyTable("Primary Key Sorted Field")

    MyTable.MoveLast

    LastRec = MyTable("Primary Key Sorted Field")

    MyTable.Close



    Select Case Me.Primary_Key_Sorted_Field

        'If you're on the first record, disable the PREV button and gray

        'out its label.  Do the opposite to the NEXT button.

        Case FirstRec

            Me.Next_Record_Button.Enabled = True

            Me.Next_Record_Button_Label.ForeColor = vbBlack

            Me.Previous_Record_Button.Enabled = False

            Me.Previous_Record_Button_Label.ForeColor = RGB(128,128,128)

        'If you're on the last record, disable the NEXT button and gray

        'out its label.  Do the opposite to the PREV button.

        Case LastRec

            Me.Next_Record_Button.Enabled = False

            Me.Next_Record_Button_Label.ForeColor = RGB(128,128,128)

            Me.Previous_Record_Button.Enabled = True

            Me.Previous_Record_Button_Label.ForeColor = vbBlack

        'If you're NOT either first or last record, enable both

        'Their labels should be black, not gray.

        Case Else

            Me.Next_Record_Button.Enabled = True

            Me.Next_Record_Button_Label.ForeColor = vbBlack

            Me.Previous_Record_Button.Enabled = True

            Me.Previous_Record_Button_Label.ForeColor = vbBlack

    End Select



Notes:



The "TableInQuestion" is your underlying table.



The datatypes of "FirstRec" and "LastRec" should be the same as "Primary 

Key Sorted Field".  In my case, it was a string.



For "Primary Key Sorted Field" choose the primary key in your table that 

you sort by.  That is, if your forms sorts the table before opening.



RBG(128,128,128) is the color gray.  Too bad there's no vbGray.



The code above will NOT work if "Primary Key Sorted Field" is not a 

primary key.  If more than one piece of data can have the same value for 

that field, your buttons may think you're at the beginning or end when 

you're really in the middle somewhere.



Greg

Message #4 by gail711@g... on Mon, 21 Jan 2002 12:41:21
> 

> This is a multi-part message in MIME format.

> 

> ------=_NextPart_000_00F1_01C1A072.A97900C0

> Content-Type: text/plain;

> 	charset="iso-8859-1"

> Content-Transfer-Encoding: quoted-printable

> 

> Hello!!!

> 

>    Hi!!!  I made a set of buttons similar to the Record Navigation of 

> the form.  I was just wondering on how I could disabling the next button 



> to make a new record if its in the last record of the table.  What I did 



> is went to Form properties and set "Allow Additions" to No, now the 

> probLem is with this setting I could not even add a new record even I 

> used the add button.  Any idea?  Thanks!!!

> 

> Enzo :)

> 

> ------=_NextPart_000_00F1_01C1A072.A97900C0

> Content-Type: text/html;

> 	charset="iso-8859-1"

> Content-Transfer-Encoding: quoted-printable

> 

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

> <HTML><HEAD>

> <META http-equiv=3DContent-Type content=3D"text/html; 

> charset=3Diso-8859-1">

> <META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR>

> <STYLE></STYLE>

> </HEAD>

> <BODY bgColor=3D#ffffff>

> <DIV><FONT face=3DVerdana size=3D2>Hello!!!</FONT></DIV>

> <DIV><FONT face=3DVerdana size=3D2></FONT>&nbsp;</DIV>

> <DIV><FONT face=3DVerdana size=3D2>&nbsp;&nbsp; Hi!!!&nbsp; I made a set 



> of buttons

> similar to the Record Navigation of the form.&nbsp; I was just wondering 



> on how

> I could disabling the next button to make a new record if its in the 

> last record

> of the table.&nbsp; What I did is went to Form properties and set "Allow 



> 

> Additions" to No, now the probLem is with this setting I could not even 

> add a

> new record even I used the add button.&nbsp; Any idea?&nbsp;

> Thanks!!!</FONT></DIV>

> <DIV><FONT face=3DVerdana size=3D2></FONT>&nbsp;</DIV>

> <DIV><FONT face=3DVerdana size=3D2>Enzo :)</FONT></DIV></BODY></HTML>

> 

> ------=_NextPart_000_00F1_01C1A072.A97900C0--

> 



Hi

In the next button code use the following and it should stop you being 

allowed to go to a new record



DoCmd.GoToRecord , , acNext

        

If Me.NewRecord Then

     DoCmd.RunCommand acCmdRecordsGoToPrevious

End If



Works for me.  Just puts you back to the last record.  

Hope this helps

Message #5 by "Paul McLaren" <paulmcl@t...> on Mon, 21 Jan 2002 15:55:34 -0000
Another solution to this problem is to use an error trap, not quite as

visually spectacular as disabling the buttons but try this for the

buttons OnClick Event



On Error goto trap



DoCmd.GoToRecord , , acNext

        

Trap:



Exit sub



No code is actually required for when the error occurs at the routione

goes to 'trap:', it just captures the error then exits the OnClick

event.



Regards



Paul







-----Original Message-----

From: gail711@g... [mailto:gail711@g...] 

Sent: 21 January 2002 12:41

To: Access

Subject: [access] Re: New record by clicking the NEXT button





> 

> This is a multi-part message in MIME format.

> 

> ------=_NextPart_000_00F1_01C1A072.A97900C0

> Content-Type: text/plain;

> 	charset="iso-8859-1"

> Content-Transfer-Encoding: quoted-printable

> 

> Hello!!!

> 

>    Hi!!!  I made a set of buttons similar to the Record Navigation of 

> = the form.  I was just wondering on how I could disabling the next 

> button



> to make a new record if its in the last record of the table.  What I 

> did



> is went to Form properties and set "Allow Additions" to No, now the = 

> probLem is with this setting I could not even add a new record even I 

> = used the add button.  Any idea?  Thanks!!!

> 

> Enzo :)

> 

> ------=_NextPart_000_00F1_01C1A072.A97900C0

> Content-Type: text/html;

> 	charset="iso-8859-1"

> Content-Transfer-Encoding: quoted-printable

> 

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 

> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; 

> charset=3Diso-8859-1">

> <META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR>

> <STYLE></STYLE>

> </HEAD>

> <BODY bgColor=3D#ffffff>

> <DIV><FONT face=3DVerdana size=3D2>Hello!!!</FONT></DIV>

> <DIV><FONT face=3DVerdana size=3D2></FONT>&nbsp;</DIV>

> <DIV><FONT face=3DVerdana size=3D2>&nbsp;&nbsp; Hi!!!&nbsp; I made a

set 



> of buttons

> similar to the Record Navigation of the form.&nbsp; I was just 

> wondering



> on how

> I could disabling the next button to make a new record if its in the 



> last record=20 of the table.&nbsp; What I did is went to Form 

> properties and set "Allow



> 

> Additions" to No, now the probLem is with this setting I could not 

> even = add a=20 new record even I used the add button.&nbsp; Any 

> idea?&nbsp;=20 Thanks!!!</FONT></DIV>

> <DIV><FONT face=3DVerdana size=3D2></FONT>&nbsp;</DIV>

> <DIV><FONT face=3DVerdana size=3D2>Enzo :)</FONT></DIV>

---<BR>

Change your mail options at http://p2p.wrox.com/manager.asp or <BR> to

unsubscribe send a blank email to $subst('Email.Unsub').

</BODY></HTML>

> 

> ------=_NextPart_000_00F1_01C1A072.A97900C0--

> 



Hi

In the next button code use the following and it should stop you being 

allowed to go to a new record



DoCmd.GoToRecord , , acNext

        

If Me.NewRecord Then

     DoCmd.RunCommand acCmdRecordsGoToPrevious

End If



Works for me.  Just puts you back to the last record.  

Hope this helps







Message #6 by "Zaragoza, Enzo" <enzaux@y...> on Wed, 30 Jan 2002 23:11:37 +0800
This is a multi-part message in MIME format.



------=_NextPart_000_0175_01C1A9E3.77F1CC10

Content-Type: text/plain;

	charset="iso-8859-1"

Content-Transfer-Encoding: quoted-printable



I've tried deleting the data on the table, now the problem is that when 

I open the form the form objects do not show since the form is not 

allowed on to make additions.  What I did is initially manually fill the 

first record of the table so that in anyways at start the from will show 

the objects.  Is there any great ideas there?



Thanks,



Enzo

  ----- Original Message -----

  From: Lonnie Johnson

  To: Access

  Sent: Friday, January 18, 2002 10:54 PM

  Subject: [access] Re: New record by clicking the NEXT button





  In your Add Button's On Click procedure, put code set the Allow 

Additions property to Yes. 



  Me.AllowAdditions =3D True



  Then in the Form's After Update Event set it back to False.



  Hope this helps ya.



  



    Enzo Zaragoza <enzaux@g...> wrote:



    Hello!!!



       Hi!!!  I made a set of buttons similar to the Record Navigation 

of the form.  I was just wondering on how I could disabling the next 

button to make a new record if its in the last record of the table.  

What I did is went to Form properties and set "Allow Additions" to No, 

now the probLem is with this setting I could not even add a new record 

even I used the add button.  Any idea?  Thanks!!!



    Enzo :)




$subst('Email.Unsub').





  Lonnie Johnson ljprodev@y...

  ProDev, Builders of MS Access Databases

  Let ProDev build your next MS Access database application.

  http://www.galaxymall.com/software/PRODEV



  Get paid cash every time you receive email!

  Sign up FREE at: http://www.MintMail.com/?m=3D975303









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

-----

  Do You Yahoo!?

  Send FREE video emails in Yahoo! Mail. --- 

http://p2p.wrox.com/manager.asp or 

$subst('Email.Unsub').










_________________________________________________________



Do You Yahoo!?



Get your free @yahoo.com address at http://mail.yahoo.com








  Return to Index