473,320 Members | 1,823 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,320 software developers and data experts.

Autofilling field from query to form

19
Hello - I've made a form with a subform of the same table, which is for Dr's notes. On the subform I have the query sorting in decending order and a criteria to enter a patient's name so the last note written for that patient shows on the subform.

How can I make it so that when a patient's name is entered for the subquery, that name automatically fills the name field on the blank note form? Or when a name is entered into the name field on the Blank note how can I have it run the subnote query to find the notes for that patient?

Any help would be greatly appreciated.

Thank you
Laura
Feb 24 '09 #1
9 1621
ADezii
8,834 Expert 8TB
@Ledmark
Hello Laura, post the SQL, with the Criteria, that comprises the Record Source for your Sub-Form.
Feb 26 '09 #2
Ledmark
19
OK - here is the SQL, including the criteria, for the sub form:

SELECT tblNote.NoteDate, tblNote.NotePtName, tblNote.[Note-S], tblNote.[Note-O], tblNote.[Note-A], tblNote.NoteReccomd
FROM tblNote
WHERE (((tblNote.NotePtName)=[Enter Patient's Name]))
ORDER BY tblNote.NoteDate DESC;

This is something else I tried - I put a combo box on the form called frmOptionBoard that has a list of patient names based on a table called tblIdentity. When a name is selected on the option board I want to then be able to click on one of the options, which opens a form and I'll use the frmNotes as an example, and when the form loads I want the form opening up to look at the patient name chosen in the Combo Box and then autofill it into the NotePtName field on the Note Form. I don't know how to say this in code - I tried this but it didn't work:

If Len(Me.[NotePtName] & "") = 0 Then
Me.[NotePtName] = Me.[frmOptionBoard.Combo26]
End If

I know what I want to do is possible but I just don't know how to word it.

Thanks again for any help.

Laura
Feb 27 '09 #3
ADezii
8,834 Expert 8TB
@Ledmark
You can include the actual Parameter itself as a Field Name directly in the SQL, where it can easily be referenced as [PName]:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblNote.NoteDate, tblNote.NotePtName, tblNote.[Note-S], tblNote.[Note-O], tblNote.[Note-A], tblNote.NoteReccomd, 
  2. [Enter Patient's Name] As PName
  3. FROM tblNote
  4. WHERE (((tblNote.NotePtName)=[Enter Patient's Name]))
  5. ORDER BY tblNote.NoteDate DESC;
Feb 27 '09 #4
Ledmark
19
OK - I'm assuming this is the SQL I put into the Sub Query so I'm going to give it a whirl.

Thank you for your help. If it doesn't work I'll be back :)

Laura
Feb 27 '09 #5
Ledmark
19
OK - I put this exact thing into the Note Sub query:

SELECT tblNote.NoteDate, tblNote.NotePtName, tblNote.[Note-S], tblNote.[Note-O], tblNote.[Note-A], tblNote.NoteReccomd
[Enter Patient's Name] As PName
FROM tblNote
WHERE ((tblNote.NotePtName)=[Enter Patient's Name]))
ORDER BY tblNote.NoteDate DESC;

and tried to save it and this is what I got:

Syntax Error (missing operator) in Query Expression 'tblNote.Recommd [Enter Patient's Note]'.

Nothing I tried worked - maybe I'm just retarded :( frustrated.

Is there a way to write code for the Note form On Load that tells the form to look at the combo box for the name and have it autofill the NotePtName field and the parameter query?

What about something in the form properties On Load like this:

Me.[NotePtName] = Me.[frmOptionBoard.Combo26] Is it really this hard??

Laura
Feb 27 '09 #6
ADezii
8,834 Expert 8TB
@Ledmark
Forgot the Comma after tblNote.NoteReccomd
Expand|Select|Wrap|Line Numbers
  1. tblNote.NoteReccomd,
  2. [Enter Patient's Name] As PName
Feb 27 '09 #7
Ledmark
19
OK - I'll try it again. Thank you for all your help.

Laura
Feb 27 '09 #8
Ledmark
19
I tried it again just like you said in the sub form query and nothing happened - it didn't work.

Laura
Feb 27 '09 #9
ADezii
8,834 Expert 8TB
@Ledmark
Create another Text Box on the Sub-Form (you can hide it if you like), and set its Control Source to PName. You can now refer to this Field by:
Expand|Select|Wrap|Line Numbers
  1. Forms![Main Form]![Sub-Form Control Name].Form![PName]
Feb 27 '09 #10

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

Similar topics

3
by: MX1 | last post by:
I have a query written in MS Access that has a few calculated fields. Is it possible to refer to that query in a form field. I'd like the form field to show the sum of one of the columns from the...
1
by: Old Timer | last post by:
I wish to type in a number in my "Code" field, for instance 1060, I then wish the number 1060 to trigger an event that will fill in the next field (township field) For instance, 1060 brings up and...
3
by: John young | last post by:
I have been looking for an answer to a problem and have found this group and hope you can assist . I have been re doing a data base I have made for a car club I am with and have been trying to...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
5
by: ND | last post by:
I need to create a separate field from 4 fields, "street address", "city", "State" and "zip code". For example, Street address - 100 Forest Street City - Seattle State - WA Zip - 05555 ...
18
by: DNK2007 | last post by:
Hi all, How to do autofilling of a web form in firefox using javascript. ie through java script program should do autofilling of the web form. Thanks DNK2007
3
by: DNK2007 | last post by:
Hi all, Is it possible to write a perl program that do autofilling of the login webform(username, password) of other domain (say hotmail.com). Assume domain name, username, password are passed as...
33
tdw
by: tdw | last post by:
I have a customers table that has a couple of checkbox fields. I also have an orders table with those same checkbox fields (though with a slightly different name). This is not duplicitous as I only...
5
by: z.ghulam | last post by:
Hi, I have a subform in a main form. When I create new records in the subform I would like the Subform. to autofill with the MainForm. It sounds quite simple, but ive been bustin my brains...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.