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

New record gives error in "linked" form

Hi,

Hope you can help me on this...

I got 1 form with a sub form. On this subform there are only parts of
records, so you can select the one you want to edit.
When you dubbel click that record a second form will open and you see all
info of that record(also the info that was already shown on form 1)
Now is it posible to edit the record.

So far no problem, but

On the sub form on form1 you can also dubbel click the *(add new) record.
Form 2 will open with all blank fields.
After adding the new info, form2 dont want to close, becausse its missing a
linked ID to the main form1

The way I open form 2 is:

Private Sub Form_DblClick(Cancel As Integer)
On Error GoTo Err_Form__DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Repair Query"

stLinkCriteria = "[RMA nr]=" & "'" & Me![RMA nr] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Form__DblClick:
Exit Sub

Err_Form__DblClick:
MsgBox Err.Description
Resume Exit_Form__DblClick

end sub

The main form1 is called [Monitor] with a auto ID called [Monitor ID]
The sub form is called [Repair Query Sub Form] with a linked [Rev Monitor
ID] to the main form [Monitor]
And the second form [Repair Query] " "
" " "

I also made a simple example database to show the problem:
http://groups.msn.com/MSAccessforum/...ssage&mview=1&
ID_Message=1362

Thanx
Xiphias
Nov 12 '05 #1
4 1913
Xiphias wrote:
The way I open form 2 is:

Private Sub Form_DblClick(Cancel As Integer)
On Error GoTo Err_Form__DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Repair Query"

stLinkCriteria = "[RMA nr]=" & "'" & Me![RMA nr] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Try this instead. You RMA# is in the MainForm, not the subform.
Private Sub Form_DblClick(Cancel As Integer)
On Error GoTo Err_Form__DblClick

DoCmd.OpenForm "RepairQuery",,,,acFormAdd
Forms!RepairQuery![RMA nr] = Forms!YourMainFormName[rma nr]



Exit_Form__DblClick:
Exit Sub

Err_Form__DblClick:
MsgBox Err.Description
Resume Exit_Form__DblClick

end sub

The main form1 is called [Monitor] with a auto ID called [Monitor ID]
The sub form is called [Repair Query Sub Form] with a linked [Rev Monitor
ID] to the main form [Monitor]
And the second form [Repair Query] " "
" " "

I also made a simple example database to show the problem:
http://groups.msn.com/MSAccessforum/...ssage&mview=1&
ID_Message=1362

Thanx
Xiphias


Nov 12 '05 #2

"Salad" <oi*@vinegar.com> schreef in bericht
news:3F***************@vinegar.com...
Xiphias wrote:
The way I open form 2 is:

Private Sub Form_DblClick(Cancel As Integer)
On Error GoTo Err_Form__DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Repair Query"

stLinkCriteria = "[RMA nr]=" & "'" & Me![RMA nr] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Try this instead. You RMA# is in the MainForm, not the subform.
Private Sub Form_DblClick(Cancel As Integer)
On Error GoTo Err_Form__DblClick

DoCmd.OpenForm "RepairQuery",,,,acFormAdd
Forms!RepairQuery![RMA nr] = Forms!YourMainFormName[rma nr]



Exit_Form__DblClick:
Exit Sub

Err_Form__DblClick:
MsgBox Err.Description
Resume Exit_Form__DblClick

end sub

The main form1 is called [Monitor] with a auto ID called [Monitor ID]
The sub form is called [Repair Query Sub Form] with a linked [Rev Monitor ID] to the main form [Monitor]
And the second form [Repair Query] " "
" " "

I also made a simple example database to show the problem:
http://groups.msn.com/MSAccessforum/...ssage&mview=1& ID_Message=1362

Thanx
Xiphias


Ok thanx I solved the problem like this:
----------------------------------------------------------
Private Sub Form_DblClick(Cancel As Integer)
On Error GoTo Err_Form__DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Repair Query"

stLinkCriteria = "[RMA nr]=" & "'" & Me![RMA nr] & "'"
If Me.NewRecord Then

DoCmd.OpenForm "Repair Query", , , , acFormAdd
Forms![Repair Query]![Rev Monitor ID] = [Forms]![Vrij goed]![Monitor Query
Subformulier1].Form![Monitor ID]

Else
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

Exit_Form__DblClick:
Exit Sub

Err_Form__DblClick:
MsgBox Err.Description
Resume Exit_Form__DblClick

End Sub
--------------------------------------------------------
The only problem I have now is...

after opening a new record and closing it straight away, there will be an
new record with only the [Rev Monitor ID] and the rest is blank.
So I have to make a check if the [RMA nr] is empty, if so it has to ask if I
want to save this record Yes/No.

Do you know how to make this...?

Thanx again.
Xiphias


Nov 12 '05 #3
Xiphias wrote:
--------------------------------------------------------
The only problem I have now is...

after opening a new record and closing it straight away, there will be an
new record with only the [Rev Monitor ID] and the rest is blank.
So I have to make a check if the [RMA nr] is empty, if so it has to ask if I
want to save this record Yes/No.

Do you know how to make this...?

Thanx again.
Xiphias


Well, maybe not pass the ID. Do it when the record is saved. Since the ID may
not be required for viewing, in the Single form, you can make the ID in the
single form invisibible.

When the form (single) closes, you can check to see if is modified. In the
Forms BeforeUpdate event do something like
Sub Form_BeforeUpdate()
If Me.NewRecord Then
Me.YourIDFieldName = Forms!YourMainFormThatCalledThiswForm!ID
Endif
End Sub

The above would be done ONLY if the single form is ONLY called from the
form/subform. If you call the single form by itself somewhere else then you
need to check to see your main form is open (see syscmd()) and/or add some extra
verification checks that the ID field has not been filled in yet.

Nov 12 '05 #4
I hadn't the time to try it yet, but it sounds like it could be working.
I already had a "not so nice" idea to put a button with:

DoCmd.Close

Thats also solving the problem, but I dont understand why.
What's the differents between "DoCmd.Close" and pushing the "X" to close the
window.

Do you know if its possible to connect the"DoCmd.Close" commando to the "X",
that would make a perfect solution.

Tomorrow I will try your solition. I will let you know how it worked....

Thanx,
Xiphias

"Salad" <oi*@vinegar.com> schreef in bericht
news:3F***************@vinegar.com...
Xiphias wrote:
--------------------------------------------------------
The only problem I have now is...

after opening a new record and closing it straight away, there will be an new record with only the [Rev Monitor ID] and the rest is blank.
So I have to make a check if the [RMA nr] is empty, if so it has to ask if I want to save this record Yes/No.

Do you know how to make this...?

Thanx again.
Xiphias
Well, maybe not pass the ID. Do it when the record is saved. Since the

ID may not be required for viewing, in the Single form, you can make the ID in the single form invisibible.

When the form (single) closes, you can check to see if is modified. In the Forms BeforeUpdate event do something like
Sub Form_BeforeUpdate()
If Me.NewRecord Then
Me.YourIDFieldName = Forms!YourMainFormThatCalledThiswForm!ID
Endif
End Sub

The above would be done ONLY if the single form is ONLY called from the
form/subform. If you call the single form by itself somewhere else then you need to check to see your main form is open (see syscmd()) and/or add some extra verification checks that the ID field has not been filled in yet.

Nov 12 '05 #5

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

Similar topics

3
by: LouD | last post by:
I have 5 tables in my db and when i bring up the linked form I get my product lists Tbls are tbStock, which contain unitcost, sellprice n qty tblProduct, contains ID, medicalname n genericname...
4
by: Clive | last post by:
Hi all. I'm fairly new to access (97) programming so please forgive me if this has been asked a thousand times. I have a two forms: Form A open forms B by a button/control (form B enters...
4
by: John | last post by:
I have an Invoice form and a Jobcard form. They're bound to tblInvoices and tblJobcard. These in turn have a many to many relationship through a junction table. The Jobcard form is based on a query...
19
by: davidgordon | last post by:
Hi, I need some pointers/help on how to do the following if it possible: In my access db, I have the following: Tables: Products, Sub-Assembly, Product-Pack Table, Products
2
by: monnomiznogoud | last post by:
Ok, my problem is the following: I have very complicated Access 97 databases that link through ODBC to Sybase databases. Now in some of the forms controls I had queries that used as "where...
1
by: mr_doles | last post by:
I am using vb.net 2005. In my explorer window I have a form called mail.vb linked to it are two other files mail.resx and mail.designer.vb. I created a new folder in the solution explorer called...
3
by: ivanov.alexei | last post by:
It's my first post and first DB application. Environment: MFC DAO, MS Access database I want to have several tables which have links to the fields to other tables. The following example explains...
3
by: cyber0ne | last post by:
Probably another easy question... I have two data tables. One holds the main data, the other holds additional data on a many-to-one relationship with the main data. Using the forms wizard, my...
4
by: jclover | last post by:
I have a form with a subform, and a child linked form. The main form is a data entry point for different business tracking. The child form that is opened from that is used to enter product...
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: 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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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
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
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.