Avatar billede toni01 Nybegynder
13. november 2001 - 12:38 Der er 15 kommentarer og
1 løsning

opdatere form

Problemet med nedenstående er at jeg ikke kan sætte focus på txtCategoryID, da dette felt skal være skjult.

er der nogle der har en ide?

lngRecordID = Me.lstCategories.Value
    txtCategoryID.SetFocus
    DoCmd.FindRecord lngRecordID, , , , , acCurrent
    txtCategoryName.SetFocus
Avatar billede mmt Nybegynder
13. november 2001 - 12:45 #1
Hvorfor vil du have focus på et skjult element?
Avatar billede toni01 Nybegynder
13. november 2001 - 13:25 #2
fordi dette felt forbinder formen med tabellens id.
Avatar billede terry Ekspert
13. november 2001 - 13:38 #3
you can NOT (i dont beleive) set focus on a hidden field !
Avatar billede terry Ekspert
13. november 2001 - 13:40 #4
why do you need to set focus on the field, and becuase its the field bound to the tabel IS NOT a reason, if you think it is then explain!
Avatar billede toni01 Nybegynder
13. november 2001 - 13:49 #5
by selecting af category from the listbox i want to refresh the rest of the form with the chosen record, so i can edit it.

i need another way to refresh the form with the chosen record.
Avatar billede terry Ekspert
13. november 2001 - 13:53 #6
If you use the combo box wizard it will make the code necessary to find the correct record from that chosen from the combo.
Avatar billede toni01 Nybegynder
13. november 2001 - 13:56 #7
it a listbox and i did use the wizard, but if i keep the focus on the listbox it dosent work, this works if the txtCategoryID is not hidden.

Avatar billede terry Ekspert
13. november 2001 - 13:58 #8
toni01>Could you use a combo instead of a listbox?
Avatar billede toni01 Nybegynder
13. november 2001 - 13:59 #9
well i did not cnnect the result from listbox to the txtCategoryID, if i do that it might work?
Avatar billede terry Ekspert
13. november 2001 - 14:06 #10
The code that the wizard makes looks like this, are you sure your doing it right?

Sub List8_AfterUpdate()
    \' Find the record that matches the control.
    Me.RecordsetClone.FindFirst \"[Id] = \" & Me![List8]
    Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub
Avatar billede terry Ekspert
13. november 2001 - 14:15 #11
when you use the wizard you can choose to get it to find a record on the from. If you do this then the code should look like that from my comment!
Avatar billede toni01 Nybegynder
13. november 2001 - 14:19 #12
that helped thank you

im new to access, how do i use the wizard to make events, i go directly to the codebuilder?
Avatar billede toni01 Nybegynder
13. november 2001 - 14:26 #13
But the for is not updating the listbox with the new data?
Avatar billede terry Ekspert
13. november 2001 - 14:27 #14
In the objects properties you can see the available events unbder the events Tab. Click on one of these and yiou will see a little button appear beside the field. Click on this and then choose Code builder. Access will only make sub start and end, you have to add other code yourself. Access doesnt know what you want to do.

Sometimes you will see that there are parameters to the sub for example the before update to a field
Private Sub txtDate_BeforeUpdate(Cancel As Integer)

Here you could evaluate the data and if it snot correct you could set Cancel to true which informs Access to stop updatimng the field.
Avatar billede terry Ekspert
13. november 2001 - 14:29 #15
Are you adding a record on the form and want to update the listbox?

Try Me.Me.lstCategories.requery in the AFTER UPDATE of the form
Avatar billede toni01 Nybegynder
13. november 2001 - 14:43 #16
Perfect (0:
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