Avatar billede sonic666 Novice
11. februar 2016 - 09:32 Der er 8 kommentarer og
1 løsning

Lav knap der åbner en anden form på ny post og opdaterer når man lukker

Jeg har lavet en knap i Form1 der åbner Form2. Begge forms bygger på relaterede tabeller. Jeg vil gerne have når Form2 åbner går den til "Ny post" i stedet for at åbne på post 1.


På Form2 har jeg en Luk-knap. Men jeg vil gerne have at ved at klikke Luk, lukker man ikke kun Form2, men opdaterer også Form1.
(i stedet for man skal gøre det manuelt på opdaterknappen)


Håber nogle kan hjælpe.
Avatar billede terry Ekspert
11. februar 2016 - 11:32 #1
What is to update on form1?
Avatar billede terry Ekspert
11. februar 2016 - 11:35 #2
There's a link here which I think may be of use to open form.

Answer really depends on whether or not you only want to add new records or also be able to edit existing.

https://social.msdn.microsoft.com/Forums/office/en-US/86bf000f-9b43-4cb9-88d5-1b6cf9c5d12f/go-to-new-record-on-opening-form?forum=accessdev
Avatar billede terry Ekspert
11. februar 2016 - 11:36 #3
An dif you open form 2 as dialog then you can also put a requery of form 1 after the line of code which opens form 2
Avatar billede sonic666 Novice
11. februar 2016 - 12:11 #4
...What is to update on Form1?

Form1 contain several combo-boxes that link to tabels (ex. CusomerTable)

I have made a button in Form1 that opens Form2 (Add customer).

When I add a new customer via Form2 and close it, the new date does not apear in the customer-combo-box in Form1. Not untill I press update in the toolbar.

Can this be done automatic via the "Close button" on Form2"?
Avatar billede terry Ekspert
11. februar 2016 - 13:08 #5
Though that might be the reason :-)

There's actually an event which you can use to trigger your code.

Some good examples here
http://allenbrowne.com/ser-27.html
Avatar billede terry Ekspert
11. februar 2016 - 13:08 #6
and that was an answer :-)
Avatar billede sonic666 Novice
11. februar 2016 - 13:17 #7
I dont think that's what Im looking for..
Actually I dont undestand much of it.

What I need is to update Form1 with some kind of action fra a button on Form2.

Is that possible?
Avatar billede terry Ekspert
11. februar 2016 - 13:37 #8
"Actually I dont undestand much of it." :-)

But it is actually the right way to do it, and you cant always get away from having to write code.

If you have a number of combo boxes then I guess you have a number of forms you want to open to add for example a new customer.

In the code which open the form, make sure it opens the form as a dialog. THis way the form must be closed before the code continues in form 1

EG: DoCmd.OpenForm "frmSales", acDialog ...

Now after this line of code you can requery your combo.

EG: Me.MyCombo.Requery


So you dont need to updatye form 1 from form 2
Avatar billede terry Ekspert
11. februar 2016 - 15:35 #9
I hope you got something to work, and thanks for the points
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



Seneste spørgsmål Seneste aktivitet
I dag 06:10 Excel åbner fil i kæmpe format Af Aske i Excel
I går 22:00 Datafordeler Af Lsk i PHP
I går 12:37 Summere beløb pr. dato Af TTA i Excel
31/1022:44 Tilslutte chassic fans Af viking69 i PC
31/1020:28 LED lysstofrør Af ErikHg i Fri debat