2014-05-06 61 views
0

我想做一個條件語句,基本上會說如果field1 + field2 =「string」然後做一些東西......我很確定我有東西的一部分權利,但我不認爲我有條件語句正確的...這是我VBA在訪問...如果那麼另外

txtTeam.Visible = True 
If ([GuestFirstName] + [GuestLastName] = "Angela Cockrill") Then 
    [LifetimeTxt] = "Trips of a Lifetime!" 
    txtTeam.ForeColor = vbOrange 
    txtTeam.FontSize = 14 
    txtTeam.FontBold = True 

Else 
    txtTeam.Visible = False 
    txtTeam.ForeColor = 0 

End If 

回答

1

在MS Access VBA我會用符號操作&來連接2串在一起,而不是加號,但是這只是一個偏好。您還可能需要考慮該空間,例如

txtTeam.Visible = True 
If ([GuestFirstName] & " " & [GuestLastName] = "Angela Cockrill") Then 
    [LifetimeTxt] = "Trips of a Lifetime!" 
    txtTeam.ForeColor = vbOrange 
    txtTeam.FontSize = 14 
    txtTeam.FontBold = True 

Else 
    txtTeam.Visible = False 
    txtTeam.ForeColor = 0 

End If 
0

取決於你在你的領域是什麼,你可能需要增加的空間,以及使用&號:

If ([GuestFirstName] & " " & [GuestLastName] = "Angela Cockrill") Then

相關問題