Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8816845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:42:46+00:00 2026-06-14T04:42:46+00:00

Apologise for my formatting. I am having issues with an Access database form. I

  • 0

Apologise for my formatting.

I am having issues with an Access database form.

I have a form that calls up participant info from the participant table. Then i require a subform to contain a subset of another table filtered on the id number (PK) of participant table. The subform (created by using access sub form wizard), does this job OK. (The wtwo forms are linked by ID on primary form and GI_ID on subform, but nor relevant here).

Now the tricky part, on the subform I have a button, when pressed it opens another form (clarification) and inserts a new row into then new forms table, linking bY subform (Diary.ID) and clarification.DiaryID. The operater can now fill out the fields in the clarification table, which will always be linked back to the Diary table.
In Summary

Participant table; ID (pk)
healthdiary Table; ID (PK) GI_ID (fk - participant table) form= frm_healthdiary_edit_record.ID
Clarification Table ID (PK), DiaryID (fk) form=tbl_healthdiary_clarif

This is the code behind the button which works (on another form) when it is not a subform.

SQL_Txt = "INSERT INTO tbl_healthdiary_clarif (HDR_ID) Values (forms!frm_healthdiary_record.ID)"
DoCmd.RunSQL SQL_Txt
SQL_Txt = ""
DoCmd.OpenForm "frm_healthdiary_clarif", , , "[HDR_ID] = forms!frm_healthdiary_record.ID"

The below SQL insert code does not work when used on the onClick contral on the button in the subform frm_healthdiary_record. No matter what i try it always asks for input for frm_healthdiary_record.ID.

SQL_Txt = "INSERT INTO tbl_healthdiary_clarif (HDR_ID) Values (me.frm_healthdiary_edit_record.form.ID)"
DoCmd.RunSQL SQL_Txt

SQL_Txt = ""

I have tried changing the code to me.frm_healthdiary_edit_record.form.ID and Forms!frm_healthdiary_record..Form.ID, but always get the same result of asking for input and cannot find the control.

Its very frustrating.

Let me be clear, I want the button on the subform (onclick) to 1- Insert a new row into the tbl_healthdiary_clarif then 2 – open another form based on the tbl_healthdiary_clarif at the record just inserted.

If there is a better way please suggest.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:42:47+00:00Added an answer on June 14, 2026 at 4:42 am

    You cannot include a reference to the form inside the sql text, it must be outside, as it is a variable. For example, if ID is on a subform of the current form:

    SQL_Txt = "INSERT INTO tbl_healthdiary_clarif (HDR_ID) Values ( " _
       & me.frm_healthdiary_edit_record.form.ID & ")"
    CurrentDB.Execute SQL_Txt, dbFailOnError
    

    To refer to a subform on a form outside the current form:

    SQL_Txt = "INSERT INTO tbl_healthdiary_clarif (HDR_ID) Values ( " _
       & Forms.MyFormName.frm_healthdiary_edit_record.form.ID & ")"
    

    You can also pass the ID as an OpenArg of the OpenForm method:

    DoCmd.OpenForm "Clarification", , , , , , Me.ID
    

    You can then refer to Me.OpenArgs on the form called Clarification.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a button on my windows form that calls the RunWorkerAsync() method, this
i have a query in access that is this: SELECT iif([Cup Type] like '*Cylinder*',count([Cup
I have a form that caculates the sum of amounts entered. I wanted to
I apologise if this has been asked before but I can't find the info
I apologise if there is a similar post to this that I haven't found,
Okay I do apologise that I'm out of my depth here. I'm not the
I have an idea for a program that will do a particular job for
I have been trying to position content within a table row. The row in
I want to extract rows from a file that match a particular pattern and
I have this function that iterates through a directory and is supposed to read

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.