Results 1 to 5 of 5
  1. #1
    charly.csh is offline Competent Performer
    Windows 8 Access 2007
    Join Date
    Nov 2014
    Posts
    186

    Conditional If and And to be applied for a "vbCrLf" into a textbox

    Hi everyone,



    I have a textbox named "TeamWork" and it should include the name of people to work into a project. It takes de decision according to some checkboxes Yes/No for each department.
    Into my code I am including the "vbCrLf" to make a space between names and I see a "list"


    I am also using the conditional If and Else but this is my problem, it is not working and it is going to "Else" I don't know why

    I highly appreciate the help!!


    **************************************************

    Private Sub WT_Quality_Click()

    If Me.WT_Quality = -1 And Me.TeamWorktxt = "" Then

    Me.TeamWorktxt = DLookup("[Name]", "[Team_Work]", "[Departament]= 'Quality'"


    ElseIf Me.WT_Quality = -1 And Me.TeamWorktxt <> "" Then


    Me.TeamWorktxt = Me.TeamWorktxt & " " & vbCrLf &DLookup("[Name]", "[Team_Work]", "[Departament]= 'Quality'"

    Else

    Me.TeamWorktxt = "Test failed"

    End If

    End Sub

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    I have a textbox named "TeamWork" and it should include the name of people to work into a project.
    IMHO this does not sound like a properly normalised database. Each field should contain only one piece of data. The multiple lines of data that you want to save in "TeamWork" should be in a separate table.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Agree with Bob that you should have a tblProjectMembers. To get your code working maybe try this (note you say the text box name is TeamWork yet in code you use TeamWorktxt):
    Code:
    Private Sub WT_Quality_Click()
    
    
    If Me.WT_Quality = -1 And Nz(Me.TeamWork,"") = "" Then
    
    
           Me.TeamWork = DLookup("[Name]", "[Team_Work]", "[Departament]= 'Quality'")
    
    
    
    
    ElseIf Me.WT_Quality = -1 And Nz(Me.TeamWork,"") <> "" Then
    
    
          Me.TeamWork = Me.TeamWork & " " & vbCrLf &DLookup("[Name]", "[Team_Work]", "[Departament]= 'Quality'")
    
    
    Else
    
    
    Me.TeamWork= "Test failed"
    
    
    End If
    
    
    End Sub
    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    charly.csh is offline Competent Performer
    Windows 8 Access 2007
    Join Date
    Nov 2014
    Posts
    186
    Yes..little mistake with the name of the textbox but the code pretty good!!!

    That was the thing' missing!!!

    Thank you very much!!!!

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    You're welcome, stay safe!

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Simple table relationships ("faces" to "spaces" to "chairs")
    By skydivetom in forum Database Design
    Replies: 36
    Last Post: 07-20-2019, 01:49 PM
  2. Replies: 3
    Last Post: 07-26-2017, 01:33 PM
  3. Replies: 18
    Last Post: 01-07-2016, 11:37 PM
  4. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  5. Replies: 1
    Last Post: 08-09-2012, 08:21 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