Avatar billede jensen363 Forsker
30. oktober 2014 - 12:16 Der er 8 kommentarer og
1 løsning

Run-time error '2046' Kommandoen ......

Min model består af X antal frontend databaser og 1 backend database. X brugere taster oplysninger til backend på samme tid ( typisk 2-3 brugere ) hvilket for det meste går udemærket, men af og til får en bruger denne meddelelse :

Run-time error '2046' Kommandoen eller handlingen 'Kopier' er ikke tilgængelig nu.

Den pågældende bruger kan ikke arbejde videre før den pågældende database er genstartet ....

Er der nogen Work-around

Der er nøglefelt på databasen i backend
Avatar billede MadsHaupt Juniormester
30. oktober 2014 - 13:05 #1
I hvilken sammenhæng bruger du det og er det noget du programmerer?
Avatar billede jensen363 Forsker
30. oktober 2014 - 13:27 #2
Frontend består af en hovedform og en subform, hvorfra al databehandling foregår.

Via hovedform fremsøger en bruger en record som vises i subform. Denne record skal herefter kopieres som ny record i databasen med ny unik ID ( autonum ).

Dette gøres ved hjælp af en funktionsknap på hovedform ved hjælp af følggende :

Private Sub CopyRecord_Click()
Dim db As DAO.Database

Set db = CurrentDb()

    Me.Countries_subform.Form.Dirty = False
 
    Me.Countries_subform.SetFocus
       
        DoCmd.GoToRecord , , acLast
            DoCmd.RunCommand acCmdSelectRecord
                DoCmd.RunCommand acCmdCopy
                    DoCmd.GoToRecord , , acNewRec
                        DoCmd.RunCommand acCmdPaste
                            DoCmd.RunCommand acCmdSaveRecord
   
    DoCmd.GoToRecord , , acNewRec
        DoCmd.RunCommand acCmdSelectRecord
   
    Me.Countries_subform.SetFocus
        DoCmd.GoToRecord , , acLast
            DoCmd.RunCommand acCmdSelectRecord
           
    Me.Countries_subform.Form.Refresh
           
    Me.Refresh
   
End Sub
Avatar billede MadsHaupt Juniormester
30. oktober 2014 - 16:37 #3
OK, jeg har fundet denne artikel, håber det hjælper.

Jeg programmerer, men arbejder ikke med databaser.

http://support2.microsoft.com/kb/244695
Avatar billede terry Ekspert
30. oktober 2014 - 19:57 #4
Not sue what these are here for although I dobt they have anything to do with th eproblem.


Dim db As DAO.Database

Set db = CurrentDb()


Try and debug through the code to see which line is triggering the error.

I would still suggest copying the record using SQL (ref. your preious question)
Avatar billede terry Ekspert
30. oktober 2014 - 19:57 #5
preious  previous
Avatar billede terry Ekspert
30. oktober 2014 - 20:05 #6
I don't see any reason why copying a record should give problems unless your locking the table. What locking method are you using?
Avatar billede jensen363 Forsker
03. november 2014 - 16:18 #7
I think the problem is related to the sub-table being activated.

The method used is this :

1. A record is found using the search function in the main form
2. This record is visualized in the subform
3. Using the copy function, a new record is added
4. Via this new record, a subtable is maintained

As a part of the search ( 1. ) the functionality marks/highlights the rocord to be copied.

If a user chose to close the subtable after maintaining the content, step 1-4 runs smoothly

If a user chooses to leace the subtable open/active it fails because the search function doesn't mark/highlight the correct record for copying :-(

In other words, I'm missing af function ( BeforeUpdate ) to close the subtable before a new search in performed !!!
Avatar billede terry Ekspert
03. november 2014 - 17:57 #8
Not sure I understand fully.
I assume you have separate tables for the main form and sub form

You find a record in the main form and then copy the record to the sub form (separate table)

You say "If a user chooses to leace the subtable open/active .." I assume you mean the sub form?

Is the sub form a separate form (not a sub form of the main form)?

You say "
If a user chooses to leace the subtable open/active it fails because the search function doesn't mark/highlight the correct record for copying :-("

Is this another record your trying to copy???


Any chance of seeing the DB?
Avatar billede jensen363 Forsker
19. januar 2015 - 14:15 #9
Ikke aktuel
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

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