473,471 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Coding No Related Records?

Is there a simple way to code:

If (no related records)

in VBA?

I would be going from frmMain to frm2, where frm2 may or may not have
a related record.

I do have a PK_ID in frmMain and a FK_ID in frm2.

Thanks!
amy
=---
Nov 13 '05 #1
7 1696
Use the RecordsetClone of the form that you want to check. You can use
its Find method to look for the record. Along the lines of...

Dim frm As Form

DoCmd.OpenForm "frm2" 'Let's make sure it is open.

Set frm = Forms("frm2")
RecordsetClone.FindFirst "FK_ID=" & Me.PK_ID
If frm.RecordsetClone.NoMatch Then
MsgBox "Record Not Found!"
Else
frm.Bookmark = frm.RecordsetClone.Bookmark
frm.SetFocus
End If
Set frm = Nothing

- Jim
On 2 Jul 2004 11:19:58 -0700, am*******@verizon.net (amywolfie) wrote:
Is there a simple way to code:

If (no related records)

in VBA?

I would be going from frmMain to frm2, where frm2 may or may not have
a related record.

I do have a PK_ID in frmMain and a FK_ID in frm2.

Thanks!
amy
=---


Nov 13 '05 #2
rkc

"amywolfie" <am*******@verizon.net> wrote in message
news:33**************************@posting.google.c om...
Is there a simple way to code:

If (no related records)

in VBA?

I would be going from frmMain to frm2, where frm2 may or may not have
a related record.

I do have a PK_ID in frmMain and a FK_ID in frm2.


If frm2 is loading records based on the current record of frmMain
then you can just check the recordcount property of frm2.RecordsetClone.
If it returns 0 then there are no matching records.

If frm2 is not based on frmMain then you'll need to do a FindFirst on the
frm2.RecordsetClone for a record that matches FK_ID to PK_ID.


Nov 13 '05 #3
Thanks very much for your help!

amy
===
"Jim Allensworth" <ji****@Notdatacentricsolutions.com> wrote in message news:<40**************@news.west.earthlink.net>...
Use the RecordsetClone of the form that you want to check. You can use
its Find method to look for the record. Along the lines of...

Dim frm As Form

DoCmd.OpenForm "frm2" 'Let's make sure it is open.

Set frm = Forms("frm2")
RecordsetClone.FindFirst "FK_ID=" & Me.PK_ID
If frm.RecordsetClone.NoMatch Then
MsgBox "Record Not Found!"
Else
frm.Bookmark = frm.RecordsetClone.Bookmark
frm.SetFocus
End If
Set frm = Nothing

- Jim
On 2 Jul 2004 11:19:58 -0700, am*******@verizon.net (amywolfie) wrote:
Is there a simple way to code:

If (no related records)

in VBA?

I would be going from frmMain to frm2, where frm2 may or may not have
a related record.

I do have a PK_ID in frmMain and a FK_ID in frm2.

Thanks!
amy
=---

Nov 13 '05 #4
Hi:

Can't quite get this to work -- am getting Error Msg 3070 -- The Jet
Engine does not recognize FK_Fees as valid.
That is in fact the field name in tblRevisionHistory:

Private Sub BeginCode()

On Error GoTo Error_Handler:

Dim frm As Form

DoCmd.OpenForm "frmRevisionHistory" 'Let's make sure it is open.

Set frm = Forms("frmRevisionHistory")
RecordsetClone.FindFirst "[FK_Fees] = " & Me![PK_Fees]
If frm.RecordsetClone.NoMatch Then

MsgBox "Sorry, no History record exists."

Else

frm.Bookmark = frm.RecordsetClone.Bookmark
frm.SetFocus

End If

Set frm = Nothing
Exit Sub

Error_Handler:
MsgBox Err.Description & " " & Err.Number & "NO RELATED REC!"

End Sub

Thanks!!!
===
"Jim Allensworth" <ji****@Notdatacentricsolutions.com> wrote in message news:<40**************@news.west.earthlink.net>...
Use the RecordsetClone of the form that you want to check. You can use
its Find method to look for the record. Along the lines of...

Dim frm As Form

DoCmd.OpenForm "frm2" 'Let's make sure it is open.

Set frm = Forms("frm2")
RecordsetClone.FindFirst "FK_ID=" & Me.PK_ID
If frm.RecordsetClone.NoMatch Then
MsgBox "Record Not Found!"
Else
frm.Bookmark = frm.RecordsetClone.Bookmark
frm.SetFocus
End If
Set frm = Nothing

- Jim
On 2 Jul 2004 11:19:58 -0700, am*******@verizon.net (amywolfie) wrote:
Is there a simple way to code:

If (no related records)

in VBA?

I would be going from frmMain to frm2, where frm2 may or may not have
a related record.

I do have a PK_ID in frmMain and a FK_ID in frm2.

Thanks!
amy
=---

Nov 13 '05 #5
Hmm, make sure that FK_Fees is a part of the *RecordSource* of both
forms. (It can be in the table but not a part of the RecordSource)

- Jim

On 6 Jul 2004 09:35:05 -0700, am*******@verizon.net (amywolfie) wrote:
Hi:

Can't quite get this to work -- am getting Error Msg 3070 -- The Jet
Engine does not recognize FK_Fees as valid.
That is in fact the field name in tblRevisionHistory:

Private Sub BeginCode()

On Error GoTo Error_Handler:

Dim frm As Form

DoCmd.OpenForm "frmRevisionHistory" 'Let's make sure it is open.

Set frm = Forms("frmRevisionHistory")
RecordsetClone.FindFirst "[FK_Fees] = " & Me![PK_Fees]
If frm.RecordsetClone.NoMatch Then

MsgBox "Sorry, no History record exists."

Else

frm.Bookmark = frm.RecordsetClone.Bookmark
frm.SetFocus

End If

Set frm = Nothing
Exit Sub

Error_Handler:
MsgBox Err.Description & " " & Err.Number & "NO RELATED REC!"

End Sub

Thanks!!!
===
"Jim Allensworth" <ji****@Notdatacentricsolutions.com> wrote in message news:<40**************@news.west.earthlink.net>...
Use the RecordsetClone of the form that you want to check. You can use
its Find method to look for the record. Along the lines of...

Dim frm As Form

DoCmd.OpenForm "frm2" 'Let's make sure it is open.

Set frm = Forms("frm2")
RecordsetClone.FindFirst "FK_ID=" & Me.PK_ID
If frm.RecordsetClone.NoMatch Then
MsgBox "Record Not Found!"
Else
frm.Bookmark = frm.RecordsetClone.Bookmark
frm.SetFocus
End If
Set frm = Nothing

- Jim
On 2 Jul 2004 11:19:58 -0700, am*******@verizon.net (amywolfie) wrote:
>Is there a simple way to code:
>
>If (no related records)
>
>in VBA?
>
>I would be going from frmMain to frm2, where frm2 may or may not have
>a related record.
>
>I do have a PK_ID in frmMain and a FK_ID in frm2.
>
>Thanks!
>amy
>=---


Nov 13 '05 #6
Jim:

Could you elaborate on this a little more? How can I insure that a
field is part of the RecordSource?

Thanks!

amy
===
Ji****@datacentricsolutions.com (Jim Allensworth) wrote in message news:<40***************@netnews.comcast.net>...
Hmm, make sure that FK_Fees is a part of the *RecordSource* of both
forms. (It can be in the table but not a part of the RecordSource)

- Jim

On 6 Jul 2004 09:35:05 -0700, am*******@verizon.net (amywolfie) wrote:
Hi:

Can't quite get this to work -- am getting Error Msg 3070 -- The Jet
Engine does not recognize FK_Fees as valid.
That is in fact the field name in tblRevisionHistory:

Private Sub BeginCode()

On Error GoTo Error_Handler:

Dim frm As Form

DoCmd.OpenForm "frmRevisionHistory" 'Let's make sure it is open.

Set frm = Forms("frmRevisionHistory")
RecordsetClone.FindFirst "[FK_Fees] = " & Me![PK_Fees]
If frm.RecordsetClone.NoMatch Then

MsgBox "Sorry, no History record exists."

Else

frm.Bookmark = frm.RecordsetClone.Bookmark
frm.SetFocus

End If

Set frm = Nothing
Exit Sub

Error_Handler:
MsgBox Err.Description & " " & Err.Number & "NO RELATED REC!"

End Sub

Thanks!!!
===
"Jim Allensworth" <ji****@Notdatacentricsolutions.com> wrote in message news:<40**************@news.west.earthlink.net>...
Use the RecordsetClone of the form that you want to check. You can use
its Find method to look for the record. Along the lines of...

Dim frm As Form

DoCmd.OpenForm "frm2" 'Let's make sure it is open.

Set frm = Forms("frm2")
RecordsetClone.FindFirst "FK_ID=" & Me.PK_ID
If frm.RecordsetClone.NoMatch Then
MsgBox "Record Not Found!"
Else
frm.Bookmark = frm.RecordsetClone.Bookmark
frm.SetFocus
End If
Set frm = Nothing

- Jim
On 2 Jul 2004 11:19:58 -0700, am*******@verizon.net (amywolfie) wrote:

>Is there a simple way to code:
>
>If (no related records)
>
>in VBA?
>
>I would be going from frmMain to frm2, where frm2 may or may not have
>a related record.
>
>I do have a PK_ID in frmMain and a FK_ID in frm2.
>
>Thanks!
>amy
>=---

Nov 13 '05 #7
You can look at the RecordSource of the form.

In design view of the form open the properties window for the form and
select the Data tab. Select Record Source and click the ellipsis
button to the right [...]. If a message box appears that asks if you
want invoke the query builder on the table, then you have a table as
the RecordSource. If that is the case then all of the fields that are
in the table are in the RecordSource. Otherwise the QBE window will
open and show which fields are selected from the SQL expression.
Examine that to see what is in the RecordSource - and other
information like ordering and selection criteria.

- Jim

On 7 Jul 2004 09:36:07 -0700, am*******@verizon.net (amywolfie) wrote:
Jim:

Could you elaborate on this a little more? How can I insure that a
field is part of the RecordSource?

Thanks!

amy
===
Ji****@datacentricsolutions.com (Jim Allensworth) wrote in message news:<40***************@netnews.comcast.net>...
Hmm, make sure that FK_Fees is a part of the *RecordSource* of both
forms. (It can be in the table but not a part of the RecordSource)

- Jim

On 6 Jul 2004 09:35:05 -0700, am*******@verizon.net (amywolfie) wrote:
>Hi:
>
>Can't quite get this to work -- am getting Error Msg 3070 -- The Jet
>Engine does not recognize FK_Fees as valid.
>That is in fact the field name in tblRevisionHistory:
>
>Private Sub BeginCode()
>
>On Error GoTo Error_Handler:
>
>Dim frm As Form
>
> DoCmd.OpenForm "frmRevisionHistory" 'Let's make sure it is open.
>
> Set frm = Forms("frmRevisionHistory")
> RecordsetClone.FindFirst "[FK_Fees] = " & Me![PK_Fees]
>
>
> If frm.RecordsetClone.NoMatch Then
>
> MsgBox "Sorry, no History record exists."
>
> Else
>
> frm.Bookmark = frm.RecordsetClone.Bookmark
> frm.SetFocus
>
> End If
>
> Set frm = Nothing
>
>
>Exit Sub
>
>Error_Handler:
>MsgBox Err.Description & " " & Err.Number & "NO RELATED REC!"
>
>
>
>End Sub
>
>Thanks!!!
>===
>
>
>"Jim Allensworth" <ji****@Notdatacentricsolutions.com> wrote in message news:<40**************@news.west.earthlink.net>...
>> Use the RecordsetClone of the form that you want to check. You can use
>> its Find method to look for the record. Along the lines of...
>>
>> Dim frm As Form
>>
>> DoCmd.OpenForm "frm2" 'Let's make sure it is open.
>>
>> Set frm = Forms("frm2")
>> RecordsetClone.FindFirst "FK_ID=" & Me.PK_ID
>> If frm.RecordsetClone.NoMatch Then
>> MsgBox "Record Not Found!"
>> Else
>> frm.Bookmark = frm.RecordsetClone.Bookmark
>> frm.SetFocus
>> End If
>> Set frm = Nothing
>>
>> - Jim
>>
>>
>> On 2 Jul 2004 11:19:58 -0700, am*******@verizon.net (amywolfie) wrote:
>>
>> >Is there a simple way to code:
>> >
>> >If (no related records)
>> >
>> >in VBA?
>> >
>> >I would be going from frmMain to frm2, where frm2 may or may not have
>> >a related record.
>> >
>> >I do have a PK_ID in frmMain and a FK_ID in frm2.
>> >
>> >Thanks!
>> >amy
>> >=---


Nov 13 '05 #8

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

Similar topics

0
by: Gary MacKay | last post by:
I have a typical setup with a master table that has a related table with many records per master record. Since MySql does not support sub-selects, how do I delete just the set of records I want? ...
17
by: Steve Jorgensen | last post by:
Terminology question: Is there a term for a set of records related directly or indirectly by key value in several tables? For example, a single invoice record and its line item records -or- a...
3
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I...
144
by: Natt Serrasalmus | last post by:
After years of operating without any coding standards whatsoever, the company that I recently started working for has decided that it might be a good idea to have some. I'm involved in this...
1
by: Gale Coleman - LSND | last post by:
ASP, VBscript, IIS 6, Access database Hello, I have a form page that people fill out and push submit. When they push submit, the information is stored in a database in two different tables....
29
AccessIdiot
by: AccessIdiot | last post by:
I'm sure this must be possible but I'm still a newbie and not sure how to do it. Part One: Using the good 'ol customers and orders tables and forms example - how would I go about putting a little...
11
misscrf
by: misscrf | last post by:
I have received data which contains similar records, where the customers have similar records. A customer, i.e. Jane Doe may have moved, or something, or a change to her account. When that happened...
0
by: cannonpm | last post by:
Greetings and salutations. I have developed an A2K3 MDB and have a search form modeled after Allen Browne's search form (http:// allenbrowne.com/ser-62.html). It works well except for records which...
5
WyvsEyeView
by: WyvsEyeView | last post by:
Upon clicking Delete to delete the current record on frmTopics, I want several things to happen: 1) Display a custom message rather than Access's standard "You are about to delete n records" one....
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...
1
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.