473,419 Members | 2,499 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

Finding a record, and then saving a new record after the record has been amended.

2 2Bits
Hi there,

I am very new to Access so apologies if any of this is obvious/not clear.

I am creating a data collection tool for health care employees to complete. It consists of a number of forms they will fill in. One of my forms relates to a goal based measure that the employee will fill in each time they meet with the patient (each appointment). The form is structured with patient ID, goal description, goal agreed by, goal type, goal progress and appointment date. All of this information except the goal progress and the appointment date will remain the same each time the form is filled in, so I want to create a search function by which the employee can locate the record and then amend the appointment date and goal progress and save a new record. Currently, my record which the search function is locating is just being overwritten. This is the code I have so far:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command318_Click()
  2.      'Save the current record
  3.  DoCmd.RunCommand acCmdSaveRecord
  4.  
  5.     ' Create a new record
  6.   DoCmd.GoToRecord , , acNewRec
  7.  
  8.    Dim searchValue As String
  9.     searchValue = Me.Text293.Value
  10.  
  11.     If IsNull(DLookup("[Client ID]", "[Goal Based Outcome Entry Form]", "[Client ID]='" & searchValue & "'")) Then
  12.         ' Client ID doesn't exist
  13.       If MsgBox("Client ID does NOT exist. Add as new?", vbYesNoCancel + vbQuestion, "Add New?") = vbYes Then
  14.             ' Add as a new customer
  15.        Me.[Client ID].Value = searchValue
  16.        End If
  17.     Else
  18.         ' Client ID exists
  19.      Dim strSQL As String
  20.     strSQL = "SELECT * FROM [Goal Based Outcome Entry Form] WHERE [Client ID] Like '*" & searchValue & "*'"
  21.  
  22.         ' Apply the filter to your form
  23.        Me.RecordSource = strSQL
  24.  
  25.         ' Refresh the form to display the filtered results
  26.         Me.Refresh
  27.     End If
  28. End Sub
Is anyone able to suggest a way I can make this work? Perhaps a better way would be to somehow search for a record, and then copy the values of each field to a new record? I am unsure what code would allow me to do this.
Oct 31 '23 #1

✓ answered by NeoPa

Hi Nia.

As is often the way when people post an apology in advance for any offending omissions, there is none :-D We do require code to be posted within their tags, but otherwise perfect.

Your alternative approach suggestion is also a way forward, though please read on for why it may not suit you best.

If you have a consistent target or goal that gets progressed on each visit then perhaps you could design a table with the Goal details specified. Whether this included a link to a particular Patient depends on the specific details you require, but I suspect it might.

Thus you have entities for Employees, Patients, Goals (Presumably each Goal is specific to both Employee & Patient records.) & Progress. In your system you allow the employee to identify themselves first (Before opening this form but where the details are available to it). Thus, on your form, you can start with Employee selected and prompt them to select a patient and goal (It may be that goals are unique to an employee/patient pair but that's beyond my current understanding.) before allowing them to enter progress details.

With Normalisation (See Database Normalisation and Table Structures.) you want to avoid duplicating data as much as possible. This form is specifically for updating progress. More accurately to add new progress records. Progress changes on this form but not any of :
  1. The Goal.
  2. The Employee.
  3. The Patient.

Does all that make sense?

3 24314
NeoPa
32,556 Expert Mod 16PB
Hi Nia.

As is often the way when people post an apology in advance for any offending omissions, there is none :-D We do require code to be posted within their tags, but otherwise perfect.

Your alternative approach suggestion is also a way forward, though please read on for why it may not suit you best.

If you have a consistent target or goal that gets progressed on each visit then perhaps you could design a table with the Goal details specified. Whether this included a link to a particular Patient depends on the specific details you require, but I suspect it might.

Thus you have entities for Employees, Patients, Goals (Presumably each Goal is specific to both Employee & Patient records.) & Progress. In your system you allow the employee to identify themselves first (Before opening this form but where the details are available to it). Thus, on your form, you can start with Employee selected and prompt them to select a patient and goal (It may be that goals are unique to an employee/patient pair but that's beyond my current understanding.) before allowing them to enter progress details.

With Normalisation (See Database Normalisation and Table Structures.) you want to avoid duplicating data as much as possible. This form is specifically for updating progress. More accurately to add new progress records. Progress changes on this form but not any of :
  1. The Goal.
  2. The Employee.
  3. The Patient.

Does all that make sense?
Oct 31 '23 #2
nia12
2 2Bits
Hi NeoPa,

Thank you very much for your advice on this - that does indeed make a lot of sense. I am coming to realise that I have a lot to learn around normalisation so will read up on this before designing the tool further.
Nov 1 '23 #3
NeoPa
32,556 Expert Mod 16PB
Hi Nia.

That sounds like good thinking.

NB. I reset your Best Answer as you'd assigned it to your own post - I assume by mistake. Certainly that would not be appropriate.

I look forward to hearing more from you. We like problems to help deal with :-)
Nov 1 '23 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Gabriel Harrison | last post by:
Hi, I have a mysql db with with autoincrementing primary keys in each table. I want to allow a user to add a record using a php webpage. Once the page is added how can I re SELECT that record...
1
by: Tom Cusick | last post by:
We have a Job Shop database. When I get an order in I put all the line item information into the database. Some orders have multiple lines and most of the information is the same. (eg. Customer...
1
by: matthewemiclea | last post by:
I have a subform, where in the "on current" event, I display code that is supposed to recognize which record I am pointing to, and then display more specific info in another subform based on that...
2
by: Mark Vergara | last post by:
Hi! Is there any way of finding of what position in a particular record ? For example I have 3 records 1 Record 1.. 2 Record 2.. 3 Record 3..
1
by: Cesar Zapata | last post by:
Hi, I have a a bound subform and what i'm trying to do is do check if some criteria applies before saving the record and trigger a macro. basically this is what I got. Date Received ...
6
by: Aussie Rules | last post by:
Hi, In all my coding to date, i have been dealing with multiple results in my dataset, looping through them with SqlDataAdapterContactProfile.Fill(contact, "Profile") For Each pRow In...
1
by: srinivasarao yarru | last post by:
hi friends, i am getting one problem in my software can you plz try to currect that thing. In my project total 5 tables are there.from table 3 onwards i gave composite primarey key. ...
1
by: cvillav | last post by:
Hello, I am new to Access and this forums, I have two tables and two forms to display the data. Tables Tbuilding Tcriteria Forms fmbuilding
10
by: ncsthbell | last post by:
I have inherited an access database that has the forms designed so when a user makes a change in any column(text box), there is a bar on the left of the form and a pencil appears. If the user does...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.