Avatar billede rickie Juniormester
16. december 2014 - 14:37 Der er 9 kommentarer og
1 løsning

Opdatere/vise detaljer i Access

Hej,

Jeg har en form (frmLabel) og i denne har jeg en tab og fölgende kode:

---
Private Sub tab01_Change()
   
    Select Case Me.tab01.Value
     
      Case 0
     
        Dim Qdf1 As QueryDef
        On Error Resume Next
        CurrentDb.QueryDefs.Delete "myQ"
        On Error GoTo 0
     
        Set Qdf1 = CurrentDb.CreateQueryDef("myQ")
        Qdf1.SQL = "SELECT tblSearch.* FROM tblSearch"
       
      Case 1
     
        Dim Qdf2 As QueryDef
        On Error Resume Next
        CurrentDb.QueryDefs.Delete "myQ"
        On Error GoTo 0

        Set Qdf2 = CurrentDb.CreateQueryDef("myQ")
        Qdf2.SQL = "SELECT tblLabel.* FROM tblLabel"

  End Select


End Sub

---

Det jeg vil men ikke kan få til, at fungere er at jeg vil at detail (hvor data präsenteres, skal opdateres, da jeg henter data udfra case/faneblad.

Har prövet de fleste onevents, men kan ikke få det til, at virke.
Håber i kan hjälpe og kan sende db, hvis det er aktuelt.

Mvh Rickie
Avatar billede terry Ekspert
16. december 2014 - 14:51 #1
Can you explain in more detail please?

You have a tab control with two pages?
Does each page have a sub form on it?

What are you trying to do with the querydef(s)?
As far as I can see, once they are created they will never change (no parameters/criteria)
Avatar billede rickie Juniormester
16. december 2014 - 16:18 #2
Hi Terry,

Yes thats correct - one tab control with two pages.

When selecting tab one (Sök) it should select from tblSearch and when selecting tab two (Etiketter) then it selects from another table. All is inserted into myQ AND WORKS :-)

Now whats not working is that i want to show it in detail area in the form. Some kind of "on-change" i presume. The form (frmLabel) has myQ as a data source.

Hope you understand how i mean?
Avatar billede terry Ekspert
16. december 2014 - 16:28 #3
If theres a sub form on the tab then why cant the forms record source be used?

All is inserted into myQ AND WORKS :-)
Not sure I understand that! Are you using a query (myQ) as the forms record source? (Same for BOTH sub forms)???

Any chance of seeing dB?
ekspertenATsanthell.dk
AT = @
Avatar billede rickie Juniormester
16. december 2014 - 16:38 #4
I've sent you the DB to your mail. You will understand when you se it :-)
Check myQ for everytime you choose the pages (Sök and Etiketter)

:-)
Avatar billede terry Ekspert
16. december 2014 - 17:04 #5
Got it. Will get back asap
Avatar billede terry Ekspert
16. december 2014 - 17:30 #6
I think this is what your after

    Select Case Me.tab01.Value
     
      Case 0
     
        CurrentDb.QueryDefs("myQ").SQL = "SELECT tblSearch.* FROM tblSearch"
        Me.RecordSource = "myQ"
       
      Case 1
     
       
        CurrentDb.QueryDefs("myQ").SQL = "SELECT tblLabel.* FROM tblLabel"
        Me.RecordSource = "myQ"
       
       
  End Select
Avatar billede terry Ekspert
16. december 2014 - 17:31 #7
But you could also just set the record source to the SQL
Avatar billede terry Ekspert
16. december 2014 - 17:33 #8
If the form always opens on the first tab then you also need to set the query sql to the tblSearch, but if you set the recordsource to the SQL for case 0 it will always be set to that when opening the form.
Avatar billede rickie Juniormester
17. december 2014 - 08:06 #9
Perfect. Thats just what i wanted. Thank you so much :-) Answer for points.
Avatar billede terry Ekspert
17. december 2014 - 08:32 #10
great
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