I would like to know how to write an expression

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KatieB
    New Member
    • Dec 2009
    • 1

    I would like to know how to write an expression

    I am so totally new at this it is not funny. I am desiging a database for my work and want to know, what to me should be the simplest thing, how to write an expression that automatically puts the full name on the top of the form.
    I have tried it so many ways and the nearest I can get is to get the Primary Key identifer.
    This is the expression I have: =(ContactName: [FirstName] & " " & [LastName])
    and I keep getting the error message about having an operand without an operator!

    Can someone please help me.

    Kate.
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Assuming [ContactName] is a Calculated Field in the underlying Record Source for the Form, then the following code will position the Value of this Field in a Label Control named lblName in the Form's Header Section for each Record:
    Code:
    Private Sub Form_Current()
    If Not Me.NewRecord Then
      Me![lblName].Caption = [ContactName]
    Else
      Me![lblName].Caption = ""
    End If
    End Sub

    Comment

    • Delerna
      Recognized Expert Top Contributor
      • Jan 2008
      • 1134

      #3
      You don't mention where your expression is.
      Is it in a query or is in in VBA code on the form?

      in the expression x=100 - 10
      100 and 10 are operands and the minus sign is the operator

      in your expression
      ???=(ContactNam e: [FirstName] & " " & [LastName])

      you have 4 operands
      ContactName: , [FirstName] , " " and [LastName]

      You have no operator between the two operands
      ContactName: and [FirstName]
      Hence the error operand without an operator

      at least, that is how it looks to me
      It appears to me that this is what you mean
      ???=("ContactNa me: " & [FirstName] & " " & [LastName]) if its vba

      or

      ContactName: ([FirstName] & " " & [LastName]) if its a calculated field in a query

      Comment

      Working...