Results 1 to 3 of 3
  1. #1
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102

    Table takes over data from form

    Hello all,


    I have a form (The name is "foOfferteInhalt"), this form gives the table "tblOfferte10Einträge" the data it needs.


    However, the problem is this, I have this table here:
    Click image for larger version. 

Name:	Screenshot 2022-11-14 164811.png 
Views:	12 
Size:	3.5 KB 
ID:	49111
    And I have this form:


    Click image for larger version. 

Name:	Screenshot 2022-11-14 164828.png 
Views:	11 
Size:	3.1 KB 
ID:	49112

    The field "Anzahl" and the radio button "Per" are both responsible for the field "Anzahl" in the table. So when the user clicks on "Per", I want the table to show "Per" in the "Anzahl" field. And if "Per" is not clicked, the entry from the "Anzahl" field should be taken over.
    I have written this code but it doesn't quite work:
    Code:
     Set db = CurrentDb
        Set rs = db.OpenRecordset("tblOfferte10Einträge")
          
        If Not IsNull(Forms!foOfferteInhalt!Bezeichnung1_0) Then
              With rs
                .AddNew
                
                !Bezeichnung = Me!Bezeichnung1_0
                !Einheit = Me!Einheit1
                !Anzahl = Me!Anzahl1
                If Not IsNull(Forms!foOfferteInhalt!Per1_0) Then
                !Anzahl = Me!Per1_0
                End If
                !Einheitspreis = Me!Total1
                !Summe = Me!Summe1
                !Untertext = Me!Untertext1
                
                
                .Update
            End With
        End If
        rs.Close
        Set rs = Nothing
        db.Close
        Set db = Nothing
    Do you have a solution?

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,122
    A radio (option) button will never be Null, it is either 0 (False) or -1 (True), so these lines should be:
    Code:
    'If Not IsNull(Forms!foOfferteInhalt!Per1_0) Then
         '!Anzahl = Me!Per1_0
    'End If 
    !Anzahl =IIF(Me!Per1_0=True,"Per", Me.Anzahl)
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    If per is an option button, it won't ever have a null value it will be 0 or 1(-1?) I would have thought, so your code won't ever switch.
    Something like


    !Anzahl = IIF(Me.Per1_0 = 0, Me.Anzahl , "Per")
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 11-09-2017, 08:45 PM
  2. Replies: 6
    Last Post: 12-15-2015, 04:11 PM
  3. Replies: 2
    Last Post: 11-18-2014, 01:27 PM
  4. Replies: 2
    Last Post: 05-27-2013, 09:25 AM
  5. Replies: 9
    Last Post: 10-09-2009, 08:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums