Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Creating Intelligent Navigation Buttons


Message #1 by "Sicco Ens" <sicco.ens@v...> on Wed, 29 Jan 2003 09:55:37
Being not happy with the way buttons work in a form I was searching for a 
method to make them more sophisticated. In 'Beginning Access 97 VBA 
Programming' I thought I found on page 173 and further where I was looking 
for, disabling buttons on first and last records. In the 'Whisky-database' 
that came with the book, the code worked the way I want it to work. 

I used the code for my own database, translated in dutch and adapted to my 
database, leaving the other parts as they were. To my disappointment it 
did not work. I got following errormessage: (translatedfrom Dutch, so the 
real message may read something different): Error 13 during operation
Types do not match (maybe: Type mismatch) By pressing the button 'Debug' I 
am leaded to the line: Set recClone = Me.RecordsetClone() In my opinion, 
both are Recordsets of the same type so I cannot figure out what is wrong, 
I hope someone can help me.

This is the adapted code (sorry for the Dutch comments...) I indicate the 
line where the error was indicated with ** befor and after.

'
Private Sub Form_Current()

Dim recClone As Recordset
Dim intNewRecord As Integer

'Maak een kloon van de recordset die aan het formulier ten grondslag ligt 
zodat we
'daarin kunnen bewegen zonder dat de recordset van het formulier wordt 
beïnvloed.

** Set recClone = Me.RecordsetClone() **

'Als dit een nieuwe record is, schakel dan de knoppen <Volgende> en 
<Nieuwe> uit en
'de andere knoppen in. Verlaat daarna de procedure.

intNewRecord = IsNull(Me.dia_Id)
If intNewRecord Then
    Knop_Eerste_dia.Enabled = True
    Knop_Volgende_dia.Enabled = False
    Knop_Vorige_dia.Enabled = True
    Knop_Laatste_dia.Enabled = False
    Knop_Dia_toevoegen.Enabled = False
    Exit Sub
End If

'Als we tot hier zijn gekomen weten we, dat we niet in een nieuwe record 
zijn
'zodat we de knop <Nieuw> aan kunnen zetten.

Knop_Dia_toevoegen.Enabled = True

'We moeten echter ook nagaan of er géén records zijn. Als dit het geval is,
'schakelen we alle knoppen uit behalve de knop <Nieuw>.

If recClone.RecordCount = 0 Then
    Knop_Eerste_dia.Enabled = False
    Knop_Volgende_dia.Enabled = False
    Knop_Vorige_dia.Enabled = False
    Knop_Laatste_dia.Enabled = False
Else

    'Synchroniseer de huidige pointer in de beide recordsets.
    recClone.Bookmark = Me.Bookmark

    'Als er wel records zijn, ga na of we op het eerste record zijn.
    'Indien dit het geval is, schakel dan de knoppen <Eerste> en <Vorige> 
uit.

    recClone.MovePrevious
    Knop_Eerste_dia.Enabled = Not (recClone.BOF)
    Knop_Vorige_dia.Enabled = Not (recClone.BOF)
    recClone.MoveNext

    'Ga hierna na of we op het laatste record zijn.
    'Indien dit het geval is, schakel dan de knoppen <Volgende> en 
<Laatste> uit.

    recClone.MoveNext
    Knop_Laatste_dia.Enabled = Not (recClone.EOF)
    Knop_Volgende_dia.Enabled = Not (recClone.EOF)
    recClone.MovePrevious

End If

'Sluit tenslotte de gekloonde recordset.
recClone.Close

End Sub
'

Message #2 by "George Oro" <george@c...> on Wed, 29 Jan 2003 14:05:43 +0400
Check your DAO Reference. (not so sure, just try).


> -----Original Message-----
> From: Sicco Ens [mailto:sicco.ens@v...]
> Sent: Wednesday, January 29, 2003 9:56 AM
> To: Access
> Subject: [access] Creating Intelligent Navigation Buttons
>
>
> Being not happy with the way buttons work in a form I was searching for a
> method to make them more sophisticated. In 'Beginning Access 97 VBA
> Programming' I thought I found on page 173 and further where I was looking
> for, disabling buttons on first and last records. In the 'Whisky-database'
> that came with the book, the code worked the way I want it to work.
>
> I used the code for my own database, translated in dutch and adapted to my
> database, leaving the other parts as they were. To my disappointment it
> did not work. I got following errormessage: (translatedfrom Dutch, so the
> real message may read something different): Error 13 during operation
> Types do not match (maybe: Type mismatch) By pressing the button 'Debug' I
> am leaded to the line: Set recClone = Me.RecordsetClone() In my opinion,
> both are Recordsets of the same type so I cannot figure out what is wrong,
> I hope someone can help me.
>
> This is the adapted code (sorry for the Dutch comments...) I indicate the
> line where the error was indicated with ** befor and after.
>
> '
> Private Sub Form_Current()
>
> Dim recClone As Recordset
> Dim intNewRecord As Integer
>
> 'Maak een kloon van de recordset die aan het formulier ten grondslag ligt
> zodat we
> 'daarin kunnen bewegen zonder dat de recordset van het formulier wordt
> beïnvloed.
>
> ** Set recClone = Me.RecordsetClone() **
>
> 'Als dit een nieuwe record is, schakel dan de knoppen <Volgende> en
> <Nieuwe> uit en
> 'de andere knoppen in. Verlaat daarna de procedure.
>
> intNewRecord = IsNull(Me.dia_Id)
> If intNewRecord Then
>     Knop_Eerste_dia.Enabled = True
>     Knop_Volgende_dia.Enabled = False
>     Knop_Vorige_dia.Enabled = True
>     Knop_Laatste_dia.Enabled = False
>     Knop_Dia_toevoegen.Enabled = False
>     Exit Sub
> End If
>
> 'Als we tot hier zijn gekomen weten we, dat we niet in een nieuwe record
> zijn
> 'zodat we de knop <Nieuw> aan kunnen zetten.
>
> Knop_Dia_toevoegen.Enabled = True
>
> 'We moeten echter ook nagaan of er géén records zijn. Als dit het geval is,
> 'schakelen we alle knoppen uit behalve de knop <Nieuw>.
>
> If recClone.RecordCount = 0 Then
>     Knop_Eerste_dia.Enabled = False
>     Knop_Volgende_dia.Enabled = False
>     Knop_Vorige_dia.Enabled = False
>     Knop_Laatste_dia.Enabled = False
> Else
>
>     'Synchroniseer de huidige pointer in de beide recordsets.
>     recClone.Bookmark = Me.Bookmark
>
>     'Als er wel records zijn, ga na of we op het eerste record zijn.
>     'Indien dit het geval is, schakel dan de knoppen <Eerste> en <Vorige>
> uit.
>
>     recClone.MovePrevious
>     Knop_Eerste_dia.Enabled = Not (recClone.BOF)
>     Knop_Vorige_dia.Enabled = Not (recClone.BOF)
>     recClone.MoveNext
>
>     'Ga hierna na of we op het laatste record zijn.
>     'Indien dit het geval is, schakel dan de knoppen <Volgende> en
> <Laatste> uit.
>
>     recClone.MoveNext
>     Knop_Laatste_dia.Enabled = Not (recClone.EOF)
>     Knop_Volgende_dia.Enabled = Not (recClone.EOF)
>     recClone.MovePrevious
>
> End If
>
> 'Sluit tenslotte de gekloonde recordset.
> recClone.Close
>
> End Sub
> '
>
>

Message #3 by "Bob Bedell" <bobbedell15@m...> on Wed, 29 Jan 2003 14:41:51 +0000
Agreeing with George, yes, you need to set a reference to DAO 3.x, or
if you already have, you need to fully qualifiy your object
variable declaration to avoid conflict with your ADO reference:

Dim recClone As DAO.Recordset


>From: "Sicco Ens" <sicco.ens@v...>
>Reply-To: "Access" <access@p...>
>To: "Access" <access@p...>
>Subject: [access] Creating Intelligent Navigation Buttons
>Date: Wed, 29 Jan 2003 09:55:37
>
>Being not happy with the way buttons work in a form I was searching for a
>method to make them more sophisticated. In 'Beginning Access 97 VBA
>Programming' I thought I found on page 173 and further where I was looking
>for, disabling buttons on first and last records. In the 'Whisky-database'
>that came with the book, the code worked the way I want it to work.
>
>I used the code for my own database, translated in dutch and adapted to my
>database, leaving the other parts as they were. To my disappointment it
>did not work. I got following errormessage: (translatedfrom Dutch, so the
>real message may read something different): Error 13 during operation
>Types do not match (maybe: Type mismatch) By pressing the button 'Debug' I
>am leaded to the line: Set recClone = Me.RecordsetClone() In my opinion,
>both are Recordsets of the same type so I cannot figure out what is wrong,
>I hope someone can help me.
>
>This is the adapted code (sorry for the Dutch comments...) I indicate the
>line where the error was indicated with ** befor and after.
>
>'
>Private Sub Form_Current()
>
>Dim recClone As Recordset
>Dim intNewRecord As Integer
>
>'Maak een kloon van de recordset die aan het formulier ten grondslag ligt
>zodat we
>'daarin kunnen bewegen zonder dat de recordset van het formulier wordt
>beïnvloed.
>
>** Set recClone = Me.RecordsetClone() **
>
>'Als dit een nieuwe record is, schakel dan de knoppen <Volgende> en
><Nieuwe> uit en
>'de andere knoppen in. Verlaat daarna de procedure.
>
>intNewRecord = IsNull(Me.dia_Id)
>If intNewRecord Then
>     Knop_Eerste_dia.Enabled = True
>     Knop_Volgende_dia.Enabled = False
>     Knop_Vorige_dia.Enabled = True
>     Knop_Laatste_dia.Enabled = False
>     Knop_Dia_toevoegen.Enabled = False
>     Exit Sub
>End If
>
>'Als we tot hier zijn gekomen weten we, dat we niet in een nieuwe record
>zijn
>'zodat we de knop <Nieuw> aan kunnen zetten.
>
>Knop_Dia_toevoegen.Enabled = True
>
>'We moeten echter ook nagaan of er géén records zijn. Als dit het geval is,
>'schakelen we alle knoppen uit behalve de knop <Nieuw>.
>
>If recClone.RecordCount = 0 Then
>     Knop_Eerste_dia.Enabled = False
>     Knop_Volgende_dia.Enabled = False
>     Knop_Vorige_dia.Enabled = False
>     Knop_Laatste_dia.Enabled = False
>Else
>
>     'Synchroniseer de huidige pointer in de beide recordsets.
>     recClone.Bookmark = Me.Bookmark
>
>     'Als er wel records zijn, ga na of we op het eerste record zijn.
>     'Indien dit het geval is, schakel dan de knoppen <Eerste> en <Vorige>
>uit.
>
>     recClone.MovePrevious
>     Knop_Eerste_dia.Enabled = Not (recClone.BOF)
>     Knop_Vorige_dia.Enabled = Not (recClone.BOF)
>     recClone.MoveNext
>
>     'Ga hierna na of we op het laatste record zijn.
>     'Indien dit het geval is, schakel dan de knoppen <Volgende> en
><Laatste> uit.
>
>     recClone.MoveNext
>     Knop_Laatste_dia.Enabled = Not (recClone.EOF)
>     Knop_Volgende_dia.Enabled = Not (recClone.EOF)
>     recClone.MovePrevious
>
>End If
>
>'Sluit tenslotte de gekloonde recordset.
>recClone.Close
>
>End Sub
>'
>


_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*  
http://join.msn.com/?page=features/virus

Message #4 by "John Fejsa" <John.Fejsa@h...> on Thu, 30 Jan 2003 08:39:08 +1100
Recordset is NOT a function.

Change 

           Set recClone = Me.RecordsetClone()

To

            Set recClone = Me.RecordsetClone 'Don't use () with
recordsets

Hope it works for you...
 

>>> sicco.ens@v... 29/01/2003 20:55:37 >>>
Being not happy with the way buttons work in a form I was searching for
a 
method to make them more sophisticated. In 'Beginning Access 97 VBA 
Programming' I thought I found on page 173 and further where I was
looking 
for, disabling buttons on first and last records. In the
'Whisky-database' 
that came with the book, the code worked the way I want it to work. 

I used the code for my own database, translated in dutch and adapted to
my 
database, leaving the other parts as they were. To my disappointment it 
did not work. I got following errormessage: (translatedfrom Dutch, so
the 
real message may read something different): Error 13 during operation
Types do not match (maybe: Type mismatch) By pressing the button 'Debug'
I 
am leaded to the line: Set recClone = Me.RecordsetClone() In my opinion,

both are Recordsets of the same type so I cannot figure out what is
wrong, 
I hope someone can help me.

This is the adapted code (sorry for the Dutch comments...) I indicate
the 
line where the error was indicated with ** befor and after.

'
Private Sub Form_Current()

Dim recClone As Recordset
Dim intNewRecord As Integer

'Maak een kloon van de recordset die aan het formulier ten grondslag
ligt 
zodat we
'daarin kunnen bewegen zonder dat de recordset van het formulier wordt 
beïnvloed.

** Set recClone = Me.RecordsetClone() **

'Als dit een nieuwe record is, schakel dan de knoppen <Volgende> en 
<Nieuwe> uit en
'de andere knoppen in. Verlaat daarna de procedure.

intNewRecord = IsNull(Me.dia_Id)
If intNewRecord Then
    Knop_Eerste_dia.Enabled = True
    Knop_Volgende_dia.Enabled = False
    Knop_Vorige_dia.Enabled = True
    Knop_Laatste_dia.Enabled = False
    Knop_Dia_toevoegen.Enabled = False
    Exit Sub
End If

'Als we tot hier zijn gekomen weten we, dat we niet in een nieuwe record

zijn
'zodat we de knop <Nieuw> aan kunnen zetten.

Knop_Dia_toevoegen.Enabled = True

'We moeten echter ook nagaan of er géén records zijn. Als dit het geval
is,
'schakelen we alle knoppen uit behalve de knop <Nieuw>.

If recClone.RecordCount = 0 Then
    Knop_Eerste_dia.Enabled = False
    Knop_Volgende_dia.Enabled = False
    Knop_Vorige_dia.Enabled = False
    Knop_Laatste_dia.Enabled = False
Else

    'Synchroniseer de huidige pointer in de beide recordsets.
    recClone.Bookmark = Me.Bookmark

    'Als er wel records zijn, ga na of we op het eerste record zijn.
    'Indien dit het geval is, schakel dan de knoppen <Eerste> en
<Vorige> 
uit.

    recClone.MovePrevious
    Knop_Eerste_dia.Enabled = Not (recClone.BOF)
    Knop_Vorige_dia.Enabled = Not (recClone.BOF)
    recClone.MoveNext

    'Ga hierna na of we op het laatste record zijn.
    'Indien dit het geval is, schakel dan de knoppen <Volgende> en 
<Laatste> uit.

    recClone.MoveNext
    Knop_Laatste_dia.Enabled = Not (recClone.EOF)
    Knop_Volgende_dia.Enabled = Not (recClone.EOF)
    recClone.MovePrevious

End If

'Sluit tenslotte de gekloonde recordset.
recClone.Close

End Sub
'


This message is intended for the addressee named
and may contain confidential information.

If you are not the intended recipient, please
delete it and notify the sender.

Views expressed in this message are those of the
individual sender, and are not necessarily the
views of Hunter Health.

Message #5 by "Sicco Ens" <sicco.ens@v...> on Fri, 31 Jan 2003 14:06:04
> 
Recordset is NOT a function.

Change 

           Set recClone = Me.RecordsetClone()

To

            Set recClone = Me.RecordsetClone 'Don't use () with
recordsets

Hope it works for you...
 

Alas, no, this solution did not work, gave the same error....
Message #6 by "Sicco Ens" <sicco.ens@v...> on Fri, 31 Jan 2003 14:13:16
> Agreeing with George, yes, you need to set a reference to DAO 3.x, or
if you already have, you need to fully qualifiy your object
variable declaration to avoid conflict with your ADO reference:

Dim recClone As DAO.Recordset


Well, I tried this befor but then got the error (which I have to translate 
from Dutch): Compiler Error
A by the user defined datatype is not defined.

I am not sure how to handle this.
Message #7 by "Sicco Ens" <sicco.ens@v...> on Fri, 31 Jan 2003 14:17:33
I also tried: 

Dim recClone As New Recordset

But without result as well.


Message #8 by "Sicco Ens" <sicco.ens@v...> on Fri, 31 Jan 2003 15:25:31
> > Agreeing with George, yes, you need to set a reference to DAO 3.x, or
i> f you already have, you need to fully qualifiy your object
v> ariable declaration to avoid conflict with your ADO reference:

> Dim recClone As DAO.Recordset

> 
> Well, I tried this befor but then got the error (which I have to 
translate 
> from Dutch): Compiler Error
> A by the user defined datatype is not defined.

> I am not sure how to handle this.

After searching and studying I came, when in VBA-mode, upon the 
option 'Extra', where I found the sub-option 'Links' or 'references' (in 
Dutch 'Verwijzingen') and there was no reference to DAO 3.6 objects. After 
making the reference, it works as it should.

I think: Case closed! Thanks guys for giving me the good leads. 
Message #9 by "Leo Scott" <leoscott@c...> on Fri, 31 Jan 2003 06:38:54 -0800
From the VBA IDE, click Tools->References and then from the list check
Microsoft DAO 3.6 Object Library.

|-----Original Message-----
|From: Sicco Ens [mailto:sicco.ens@v...]
|Sent: Friday, January 31, 2003 2:13 PM
|To: Access
|Subject: [access] Re: Creating Intelligent Navigation Buttons
|
|
|> Agreeing with George, yes, you need to set a reference to DAO 3.x, or
|if you already have, you need to fully qualifiy your object
|variable declaration to avoid conflict with your ADO reference:
|
|Dim recClone As DAO.Recordset
|
|
|Well, I tried this befor but then got the error (which I have to translate
|from Dutch): Compiler Error
|A by the user defined datatype is not defined.
|
|I am not sure how to handle this.
|


  Return to Index