Results 1 to 2 of 2
  1. #1
    kbremner is offline Novice
    Windows Vista Access 2003
    Join Date
    Oct 2010
    Posts
    12

    combine two fields into one

    For the purposes of my database, I need to have a Last Name Field, First Name field and a File As field, however, in many cases, the File As field will be "last name, first name". So, I want to set up the form so that when the File As field gets the focus (either OnFocus or OnEnter), if it is empty, it is automatically filled with LastName, FirstName. I have attempted this with the following code:

    Private Sub FileName_Enter()



    If IsNull Then
    Me.FileName = Me.LastName + ", " + Me.FirstName
    Else: Me.FileName.SetFocus

    End Sub

    When I enter the FileAs Field, whether it is empty or not, as soon as I tab/Click it I get an error message: Compile Error, Argument Not Optional and IsNull is highlighted. If I take out the If statement and just leave me.Filename = ...... then it works. The trouble is, if something has already been entered into the FileAs field, I don't want it changed.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try the following:
    Code:
    If IsNull(Me.Filename) Then
       Me.FileName = Me.LastName & ", " & Me.FirstName
    End If

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

Similar Threads

  1. Combine the values of two fields on a form
    By nyteowl in forum Access
    Replies: 4
    Last Post: 10-15-2010, 11:16 AM
  2. Combine two fields, Null fields involved
    By yes sir in forum Access
    Replies: 9
    Last Post: 10-03-2010, 09:20 AM
  3. Combine First and Last name fields for Report
    By yes sir in forum Reports
    Replies: 32
    Last Post: 08-31-2010, 07:31 PM
  4. Combine 2 Fields to make a hyperlink
    By ahightower in forum Forms
    Replies: 2
    Last Post: 06-30-2010, 08:59 PM
  5. Combine fields into one
    By cotri in forum Forms
    Replies: 2
    Last Post: 03-04-2010, 02:42 PM

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