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

pass value to subform from mainform when edit data in mainform

I have a mainform (frm_main) with a subform (frm_pyrovola) (linked with "id", with relationship 1-many). In subform, i have a combobox field where it takes data from table/query with the code bellow in rowsource:
Expand|Select|Wrap|Line Numbers
  1. SELECT tbl_apo.per_apo FROM tbl_apo WHERE (((tbl_apo.id_apo)=[forms].[frm_main].[id])); 
  2.  
.
Everything, it is ok when I add data for first time in mainform. When I try to connect to specific record of "id" in mainform from another form which is in dataview sheet and show all data from mainform
Expand|Select|Wrap|Line Numbers
  1. Private Sub sys_Click()
  2. On Error Resume Next
  3.  
  4.  
  5.    DoCmd.OpenForm ("frm_main"), , , , acFormEdit
  6.  
  7.  
  8.     Forms![frm_main].AllowAdditions = True
  9.     Forms![frm_main].Recordset.FindFirst "id = " & Me.id
  10.     Forms![frm_main].return.Visible = True
  11.     Forms![frm_main].cmdClose.Visible = False
  12.  
  13. End Sub
  14.  
I manage to find this record, but when I click the combobox, it asks for the parameter ([forms].[frm_main].[id]). I have tried several ways to resolve it, without a posittive way.
Thanks in advance.
Jul 24 '14 #1

✓ answered by twinnyfo

Have you tried:

Expand|Select|Wrap|Line Numbers
  1. Forms![frm_main].id
I know it shouldn't matter, as Access can often disambiguate what you are trying to tell it, but this will make it clear that you are referring to another form.

But, if this is a bound control, you will have additional problems.

10 2254
twinnyfo
3,653 Expert Mod 2GB
You nneed to requery the combo box before you try to use it:

Expand|Select|Wrap|Line Numbers
  1. Me.cboComboName.Requery
Jul 24 '14 #2
Thanks for your answer, but same error. It asks about ([forms].[frm_main].[id]).
Jul 24 '14 #3
twinnyfo
3,653 Expert Mod 2GB
When are you requerying the combo box? The error is acting like the Form is not open when it is trying to gather data in the query.

At the same time, I am a little confused by teh combo box. If your query pulls "all teh records" with ID = Main_Form.ID, that should be one record. Why not just filter your subform on the ID.

Maybe I am just confused....
Jul 24 '14 #4
Sorry, but I have missed to tell you that the combo box retrieve data from another subform (frm_apo)(linked with "id", with relationship 1-many). So I have one main table (tbl_main) and two other tables (tbl_apo & tbl_pyrovola). And the combobox retrieve data from (tbl_apo).But, if in rowsource write:[CODESELECT tbl_apo.per_apo FROM tbl_apo[/code], It is ok, but I want to filter only the data with tbl_apo.id_apo)=[forms].[frm_main].[id]).
Jul 24 '14 #5
twinnyfo
3,653 Expert Mod 2GB
Again, if you are dealing with records in forms, why not just filter the form? Again, I am confused about the usage of a combo box to filter a form. If the form/subforms are related with ID, there should be no need for a combo box, as every time you move to a different record in the main form, the subform filters by the ID. At least that is how is should work.
Jul 24 '14 #6
Here is my database, so if you can check it.
Thanks in advance.
Attached Files
File Type: zip lex.zip (75.0 KB, 78 views)
Jul 24 '14 #7
twinnyfo
3,653 Expert Mod 2GB
I'm sorry, site rules typically prohibit posting and downloading DB projects. Either way, since I still don't understand the purpose of the combo box, I'm sure it would help me.
Jul 24 '14 #8
Twinnyfo, I will show some screenshots from my db to see why I need the combobox. In the last screen I would like the combobox saw only (glock,s&w, beretta).
Attached Images
File Type: jpg 1.jpg (42.3 KB, 222 views)
File Type: jpg 2.jpg (44.3 KB, 218 views)
File Type: jpg 3.jpg (41.4 KB, 177 views)
Jul 24 '14 #9
twinnyfo
3,653 Expert Mod 2GB
I'm sorry, this still does not help me. I still don't understand what you are trying to do.

I also perceive that there may be a language barrier, too, so I am trying to firugre out the intent of your forms. But I still don't understand what your forms so and how this combo box is supposed to work.

I apologize for my slowness on this, but the pictures don't help at all, unless I know what you are trying to do, which is not completely clear at this point.
Jul 24 '14 #10
twinnyfo
3,653 Expert Mod 2GB
Have you tried:

Expand|Select|Wrap|Line Numbers
  1. Forms![frm_main].id
I know it shouldn't matter, as Access can often disambiguate what you are trying to tell it, but this will make it clear that you are referring to another form.

But, if this is a bound control, you will have additional problems.
Jul 24 '14 #11

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

Similar topics

12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
5
by: Bob | last post by:
Hi Everybody I have a form called frmListBox that is connected to a table tblListBox. This is opened from a form called "frmInvoiceOrder" which has a subform called "zfrmInvoiceOrder" and...
0
by: Vladimir Scherbina | last post by:
Hello all. I am trying to edit label in TreeView node, and when I finished editing I need to get the new data, everythings is okay except that fact that I do not get a new data, that have been...
1
by: ortega.rad | last post by:
I have a form which allows you to select a record. That record has other records asscociated with it via a table. The asscociated records of the record selected on the main form are shown in a...
2
by: lindabaldwin | last post by:
Hi there all you smarter than me people! I am stuck. I have been working on this database for days and cannot figure out how to solve my problem. I have a form with two embedded subforms. The...
1
by: lchomany | last post by:
Good Day! I have a macro created to Open my subform and is embedded in the Command Button. Main Form: frmADD NEW ENTITY NAME Subform: frmEntityAwards My macro filters to the specific...
0
by: RoxyBeginner | last post by:
I created a form with a switchboard where the user click on one of the buttons. When the form load i want the user to be able to add and edit data by clicking the appropriate button. When I click...
0
by: jimgym1989 | last post by:
Hi there, I have 2 PHP files, memeber.php & view.php This is my member.php while($row = mysql_fetch_array($strSQL)){ $data .= "<tr>"; $data .= "<td>"; $data .= "<input type='checkbox'...
1
ahmedtharwat19
by: ahmedtharwat19 | last post by:
hi everybody i tied to pass value from subform to main form but it not work with me!! I need Send from subform to field in main form it work when i save the record in main form i need to...
0
by: Jagruti patel | last post by:
i can save radio buton value to database but i can't set to radio button while edit data. how can i set data to radio button ?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.