Code doesn't work after changing MRN field to text

  • Thread starter RobUCSD via AccessMonster.com
  • Start date
R

RobUCSD via AccessMonster.com

In my table, tblPtDemograhpics, I changed the MRN (Medical Record Number)
field to txt in the table where the MRN resides. Originally it was a number
field. But then I implemented a check sum routine on MRN and it doesn't work
w/o the MRN being text as some of the MRN's have leading zeros.

Now I can't get the form to load a new patient. Think it's my syntax in the,

stLinkCriteria = "[MRN]=" & Me![MRN] piece of the code. I'm probably now
refering to MRN correctly, this was the way it was set up when MRN was a
number field, and it worked then.

If somebody could take a look I'd really appreciate it. Thanks, Rob

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

Private Sub cmdNewPtLoad_Click()

Dim stDocName As String
Dim stLinkCriteria As String

On Error GoTo cmdNewPtLoad_Click_Error

DoCmd.RunCommand acCmdSaveRecord

stDocName = "frmPtDemographicNew"

stLinkCriteria = "[MRN]=" & Me![MRN]

DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmNewPt"

On Error GoTo 0
Exit Sub

cmdNewPtLoad_Click_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
cmdNewPtLoad_Click of VBA Document Form_frmNewPt"

End Sub
 
D

Douglas J. Steele

Since MRN is now a text field, you need quotes around the value to which
you're comparing it:

stLinkCriteria = "[MRN]='" & Me![MRN] & "'"

Exagerated for clarity, that's

stLinkCriteria = "[MRN]= ' " & Me![MRN] & " ' "
 
R

RobUCSD via AccessMonster.com

Doug, you sure are nice to me. Thanks, now it works. I wish you eternal
happiness. Rob
Since MRN is now a text field, you need quotes around the value to which
you're comparing it:

stLinkCriteria = "[MRN]='" & Me![MRN] & "'"

Exagerated for clarity, that's

stLinkCriteria = "[MRN]= ' " & Me![MRN] & " ' "
In my table, tblPtDemograhpics, I changed the MRN (Medical Record Number)
field to txt in the table where the MRN resides. Originally it was a
[quoted text clipped - 39 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top