Results 1 to 4 of 4
  1. #1
    Mattbro is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    95

    Enter a value in textbox to open another form using value as the record number


    Hello all,
    I've a form-‘Data Entry’ linked to a table. To allow users to examine suspected duplication, I have a query ‘PtSearch’ which feeds to a form ‘PtSearch’. If the user is concerned about duplication, they can enter the serial number in a box on the form ‘Data Entry’ which starts the ‘PtSearch’ query and opens the form ‘PtSearch’. If there is any duplication, the user can see the serial number and record number of these cases. I have a textbox called Text14 in the header of the ‘PtSearch’ form, and I want the user to be able to enter the record number of the case they want to examine, into this box. Using the AfterUpdate event, I want the code to close the PtSearch form and open the Data Entry form at the record number they entered. My coding for this is;
    Code:
    Private Sub Text14_AfterUpdate()
      DoCmd.OpenForm "DataEntry", , , "Record Number = " & Me!Text14
      DoCmd.Close acForm, "PatientSearch"
    End Sub
    ……and it hangs up on the second line of code.... "Runtime error 3075 syntax error-missing operator in query expression Record Number = xxx." Can anybody tell me what I am doing wrong? Many thanks,
    Mattbro451

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Unless you put them in, Access does *not* have Record Numbers. Access also does not like embedded spaces in names so that field, if ir exists should have been called [Record Number] being surrounded with brackets. You code is also treating this field as a number. If is a string then you would need to enclose it in single quotes in this case.
    DoCmd.OpenForm "DataEntry", , , "[Record Number] = '" & Me!Text14 & "'"
    DoCmd.Close acForm, Me.Name

  3. #3
    Mattbro is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    95
    Ah-Record Number is a field in the table. Each entry on the table is allocated a record number (autonumber). It is also the primary key for the table. I am not sure whether that makes it a number or a string.....I assume number would be correct?
    Anyhoo,
    DoCmd.OpenForm "DataEntry", , , "[Record Number] = " & Me!Text14
    seems to be doing the job nicely! Thanks for your help RuralGuy-your explanation has pointed me in the right direction regarding the hows' whys' and wherefores' of single/double quotes. Many thanks,
    Mattbro451


    Quote Originally Posted by RuralGuy View Post
    Unless you put them in, Access does *not* have Record Numbers. Access also does not like embedded spaces in names so that field, if ir exists should have been called [Record Number] being surrounded with brackets. You code is also treating this field as a number. If is a string then you would need to enclose it in single quotes in this case.
    DoCmd.OpenForm "DataEntry", , , "[Record Number] = '" & Me!Text14 & "'"
    DoCmd.Close acForm, Me.Name

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Great! And to answer your question, AutoNumbers are Long Integers.

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

Similar Threads

  1. Replies: 1
    Last Post: 05-03-2012, 02:25 PM
  2. contional open a form and enter data
    By tggsun in forum Forms
    Replies: 4
    Last Post: 12-08-2011, 03:48 PM
  3. Replies: 1
    Last Post: 07-05-2011, 11:34 PM
  4. Replies: 0
    Last Post: 10-12-2010, 06:08 AM
  5. Capture enter key on password textbox
    By sarnata in forum Forms
    Replies: 2
    Last Post: 09-09-2010, 10:41 AM

Tags for this Thread

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