Avatar billede rickie Juniormester
09. maj 2006 - 17:39 Der er 4 kommentarer og
1 løsning

Relationer i Access

Jeg har en tabell [Reciever] som indeholder kunder og en form hvor jeg taster ind.

I formen vil jeg gerne have at når man skal taste en ny kunde så finder den oplysningerne om kunden hvis de eksisterer og hvis ikke så bliver kunden oprettet.

Jeg har prövet på alle mulige måder men kan ikke få det til at virke.

Det nemmeste er hvis jeg sender filen den over :-)
Avatar billede mugs Novice
09. maj 2006 - 17:50 #1
mugs@mail.dk

Men det bliver først senere på aftenen.
Avatar billede jensen363 Forsker
10. maj 2006 - 08:43 #2
Sådan ville jeg gøre :

Hvis du har et unikt kundeid, eksempelvis et telefonnummer, kan du benytte en kombineret søgefunktion/oprette funktion ved hjælp af en kombo-boks.

AfterUpdate() udløser søgefunktionen
NotInList() udløser ny post
Avatar billede mugs Novice
10. maj 2006 - 18:43 #3
db returneret med en NotInList funktion.
Avatar billede rickie Juniormester
15. maj 2006 - 14:10 #4
Mange tak :-)
Avatar billede jensen363 Forsker
15. maj 2006 - 14:18 #5
t.o. for andre :

NotInList Event — Event Procedures Example

The following example uses the NotInList event to add an item to a combo box.

To try this example, create a combo box called Colors on a form. Set the combo box's LimitToList property to Yes. To populate the combo box, set the combo box's RowSourceType property to Value List, and supply a list of values separated by semicolons as the setting for the RowSource property. For example, you might supply the following values as the setting for this property: Red; Green; Blue.

Next add the following event procedure to the form. Switch to Form view and enter a new value in the text portion of the combo box.

Private Sub Colors_NotInList(NewData As String, _
        Response As Integer)
    Dim ctl As Control
   
    ' Return Control object that points to combo box.
    Set ctl = Me!Colors
    ' Prompt user to verify they wish to add new value.
    If MsgBox("Value is not in list. Add it?", _
        vbOKCancel) = vbOK Then
        ' Set Response argument to indicate that data
        ' is being added.
        Response = acDataErrAdded
        ' Add string in NewData argument to row source.
        ctl.RowSource = ctl.RowSource & ";" & NewData
    Else
    ' If user chooses Cancel, suppress error message
    ' and undo changes.
        Response = acDataErrContinue
        ctl.Undo
    End If
End Sub
Note  The above example adds an item to an unbound combo box. When you add an item to a bound combo box, you add a value to a field in the underlying data source. In most cases you can't simply add one field in a new record — depending on the structure of data in the table, you probably will need to add one or more fields to fulfill data requirements. For instance, a new record must include values for any fields comprising the primary key. If you need to add items to a bound combo box dynamically, you must prompt the user to enter data for all required fields, save the new record, and then requery the combo box to display the new value.
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