Avatar billede fomse Nybegynder
09. august 2001 - 10:20 Der er 12 kommentarer og
1 løsning

Navigationsknapper??

Kan man selv designe og placerer sine navigationsknapper?

Jeg har en SØG-knap hvor jeg har en hændelsesprocedure som søger i en tabel efter hvad der indtastes i et textfelt (Søgefelt11).
Nu kunne jeg godt tænke mig at få navigationsknapperne
med på formularen.

her er hændelsen:

Private Sub Søg_Click()
On Error GoTo Err_Søg_Click

    Dim db As Database
    Dim tdf As TableDef
    Dim fld As Field
    Dim fld1 As Boolean
    Dim stDocName As String
    Dim stLinkCriteria As String
       
    Set db = CurrentDb
   
    stDocName = \"\"
    stLinkCriteria = \"\"
    fld1 = True

    If Not fldIsEmpty(Me.Søgefelt11) Then
    Set tdf = db.TableDefs(\"katalog\")
           
        For Each fld In tdf.Fields
         
        If fld.Type = dbText Or fld.Type = dbDate Then
            If fld1 Then
                stLinkCriteria = stLinkCriteria & \" [\" & fld.Name & \"] Like \'*\" & Me.Søgefelt11 & \"*\'\"
                fld1 = False
            Else
                stLinkCriteria = stLinkCriteria & \" OR [\" & fld.Name & \"] Like \'*\" & Me.Søgefelt11 & \"*\'\"
            End If
           
        End If
       
        Next fld
  End If
     
    Me.Filter = stLinkCriteria
    Me.FilterOn = True
   
\'DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Søg_Click:
    Exit Sub

Err_Søg_Click:
    MsgBox Err.Description
    Resume Exit_Søg_Click
   
End Sub
Avatar billede terry Ekspert
09. august 2001 - 10:24 #1
when you say \"navigationsknapper\" I understand you to mean Next, Previous, Last, first etc. is that correct?
If so use the button wizrad and choose record navigation where you can choose which buutons to use, the code gets generated for you!
Avatar billede fomse Nybegynder
09. august 2001 - 10:46 #2
Yes i know that but the field that shows how many results (1 af 17 for instance) you got on the search is not posible to make like that!!
Avatar billede terry Ekspert
09. august 2001 - 10:49 #3
No, you have to make that bit by hand.

Or you can use the build in navigation buttons.
Avatar billede terry Ekspert
09. august 2001 - 10:50 #4
You may be able to download something from the web!
Avatar billede fomse Nybegynder
09. august 2001 - 10:55 #5
I´m no expert in VB-script and is not able to make it my self.

Can you by any chance tell me were i v´can find it?
Avatar billede terry Ekspert
09. august 2001 - 10:57 #6
I can take a look around, but cant promise you anything!
Avatar billede fomse Nybegynder
09. august 2001 - 10:59 #7
Great!! Thanks a lot
Avatar billede terry Ekspert
09. august 2001 - 11:02 #8
Here is something. NOTE that I havent tested it!

\'Building a string containg \'current record\' \'of \'num of records\' on a form.

Function hpFormRecCount(Form As Form) As String
Dim lngRecPos As Long 
Dim lngRecCount As Long
Dim strTemp As String 

If Form.NewRecord And Form.RecordsetClone.BOF Then
  strTemp = \"1 of 1\"
Exit Function

ElseIf Form.NewRecord And Not Form.RecordsetClone.BOF Then
  lngRecPos = Form.CurrentRecord
  lngRecCount = (Form.RecordsetClone.RecordCount + 1)
Else
  Form.RecordsetClone.MoveLast
  lngRecPos = Form.CurrentRecord
  lngRecCount = Form.RecordsetClone.RecordCount
End If
 
strTemp = str(lngRecPos) & \" of \" & str(lngRecCount)
hpFormRecCount = strTemp
 
End Function

Avatar billede fomse Nybegynder
09. august 2001 - 11:08 #9
Exactly where do i put this?
Avatar billede terry Ekspert
09. august 2001 - 11:13 #10
Put this in a module. Then you need a field on the form.
Then in the forms On Current event you make a call to this function, for example:

The field is called txtRecCount.

Private Sub Form_Current()
    Me.txtRecCount = hpFormRecCount(Me)
End Sub
Avatar billede fomse Nybegynder
09. august 2001 - 11:21 #11
This is perfect!! You are a genius Terry.
Avatar billede terry Ekspert
09. august 2001 - 11:22 #12
No, I dont think so, but thanks!
Avatar billede terry Ekspert
09. august 2001 - 11:24 #13
Just to let you know that it works when filtering too!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester