473,511 Members | 16,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

creating new rows in a subform

Hello,

I've a table 'A' with a reference to another table 'B'. I've created a
form with A's fields, and a subform that displays B's fields, with a
link between them in the subform properties (Master: Bref, Child: ID).

This allows the user of the form to see and edit the fields in B, but
if I want to add a new row, I get the 'You can't assign a value to
this object' message (due to the link).

To get around this, and because I wanted to have a query functionality
as well for finding other rows in B for A to reference, I createa a
button 'Create/Choose' that opens up a the B form in a dialog window,
and in that form's Current function I save the last ID chosen by that
form in a global variable:
Private Sub Form_Current()
FormsModule.LastPropertyOwned571LTypeId = Me.ID
End Sub

So in the form for A you see this code:

Private Sub btnPropOwned_Click()
Dim fmname As String
fmname = "frmPropertyOwned571LType"
DoCmd.OpenForm fmname, WindowMode:=acDialog
Me.DeclarationPropertyOwnedRef =
FormsModule.LastPropertyOwned571LTypeId
Me.Refresh
End Sub

The problem with this is that ID is NULL when you try to create a new
row in the form. If I check for NULL, and then I don't set the
FormsModule.LastPropertyOwned571LTypeId then the new record value
never gets set. I can duplicate the code so that it sets it when the
record is closed, but that seems dangerous.

My questions are:
- Is there a better way to do this?
- Is there a way to get the current record from a form that has just
closed (i.e. avoid the global variable problem)

Thanks!
- is this the best way to
Nov 13 '05 #1
0 1196

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2266
by: Laura | last post by:
Here's the situation: I'm trying to use an update query to copy data from one row to another. Here is the situation: I have 5 companies that are linked to each other. I need to show all 5...
3
1612
by: Steven | last post by:
OK.. Here's my situation. I have a subform on a parent form. When the parent form is loaded, the subreport queries data from a table in the DB. The parent form has a couple of text boxes for data...
0
1228
by: Krij | last post by:
Hi! I have a problem with the following code (behind a button on frmOrders): (structure: frmOrders->frmOrderdetails (form with subform)) strPutBack = "INSERT INTO...
7
6735
by: ppywong | last post by:
Hi, hopefully people can help: I am creating a rather simple database for a kids holiday camp. I have two main tables: tblLData (Leaders info) and tblKData (kids info). What I have done is...
4
3452
by: aflat362 | last post by:
If you look at this page on relational database design: http://r937.com/relational.html And scroll down to the "Many-to-Many Relationships" Section you will see a common database structure. ...
5
2072
by: Don Do | last post by:
Ok, this is my 2nd ever post. 1st one was solved quickly. Thanks. Now I'm stuck again. My mdb has a main form with 3 subforms. Each tied to the succeeding by single autonumberID/foreign...
3
1785
by: solargovind | last post by:
Hi, I am New to this forum. I need steps that i do in creating subform. In main form, i have one table fields like vendor,account,due amount,balance amount and Requisition_id which is...
1
11344
by: pdesh3 | last post by:
I have created a form where one text box and two command buttons named Search and Clear are present. Under all these fields I am also including a subform which displays all the values stored in...
4
2026
by: rczuba | last post by:
Problem: Creating a Default Value for a field in a subform when a field in the subform & form match. I'm trying to create a payroll database for a small home business that I have that has had...
0
7245
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
7144
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
7356
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
7427
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...
0
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.