Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2008

Tip: Looking for answers? Try searching our database.

Need Help With Auto-Population Access Form from Input Box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AlvinChadwick - 01 May 2008 19:49 GMT
I need help with getting one of my forms to auto populate if a text string is
found in the table.  The Database is used for medical record tracking of
documentation.  The key record is the SSAN (social security number).  I have
a form based on a table called TblRecords and a subform in the form based on
a table called TblPtInfo.

TblPtInfo is the unique patient information and contains no duplicate
information
What I need to happen is for the subform to update automatically if a SSAN is
typed in and is found in the table.  If it is not found then I will have the
form use the add new record.  Right now I cannot get it to work.  this is
what I have used:

Private Sub Text14_AfterUpdate()
   Dim InpSSAN As String
   Dim rsSSAN As DAO.Recordset
         
  ' Capture item code entered
  InpSSAN = Me.Text14
  ' Fetch item record from Item Master table
  Set rsSSAN = CurrentDb.OpenRecordset("SELECT * FROM TblPtInfo WHERE SSAN =
" & InpSSAN)
  ' Check item was found
  If rsSSAN.EOF Then
      MsgBox "New SSAN", vbCritical, "Error"
      rsSSAN.Close
      Set rsSSAN = Nothing
      Exit Sub
  End If
  ' Item found, copy data
  Me.ID = rsSSAN!ID
  Me.FirstName = rsSSAN!FirstName
  Me.LastName = rsSSAN!LastName
  Me.SSAN = rsSSAN!SSAN
  Me.Admission_Date = rsSSAN!Admission_Date
  Me.D_C_Date = rsSSAN!D_C_Date
  Me.Ward = rsSSAN!Ward
  ' Finished with recordset
  rsSSAN.Close
  Set rsSSAN = Nothing

End Sub

This does not work as it always gives me the "New SSAN" error even on a known
SSAN.
I would also like to tie it into the main record to update the SSAN field on
that form.
Please help if you can.  I am new at this and tinkering with other code as I
learn what it is doing.
ruralguy - 01 May 2008 22:50 GMT
Your SSN field is a text field so you need quotes.  Here's a pretty good
explaination
on the syntax: http://www.mvps.org/access/general/gen0018.htm

Having said that, normalization rules demand that the data *only* exist in
one table in your system.  All you should need in other tables is the
PrimaryKey as a ForeignKey.  Then use a join in a query to access all of the
data in the two tables. Post back here if you need further details.

>I need help with getting one of my forms to auto populate if a text string is
>found in the table.  The Database is used for medical record tracking of
[quoted text clipped - 45 lines]
>Please help if you can.  I am new at this and tinkering with other code as I
>learn what it is doing.

Signature

RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.