A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Creating new record in linked form



 
 
Thread Tools Display Modes
  #1  
Old April 23rd, 2008, 02:43 PM posted to microsoft.public.access.forms
4charity
external usenet poster
 
Posts: 28
Default Creating new record in linked form

I have done this before, without using any coding (just the property sheet in
Access), but can't remember how to do it. Hope someone can help.

I have two forms linked. I have a main form, with a button on it to the
second form. I used the Wizard so that only the related records on the second
form show up. That works fine. Here's my problem: If I am creating a brand
new customer on my main form, and click on the button to enter related data
on the second form, the info does not show up. I have running off of a query
with the Key field joined, so that's where the problem is.... it doesn't
exist in the second form yet, so the record is not in the query. I know there
is another, easy way to do this.
?????
Thanks.
  #2  
Old April 23rd, 2008, 03:51 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Creating new record in linked form

When you add a new record in a form, it is not yet in the underlying tables.
It only exists in the form's recordset. To force it to update the data into
the table, you have to requery the form. When you do, the form recordset
will then go back to the first record in the form recordset. There is a way
to make the form appear to stay on the same record. You first need to save
the primary key field of the current record, requery the form, then use the
FindFirst method to return to the record. You can do that in the click event
of the command button where you open the other form. This example assumes
your table has an autonumber primary key.

Dim lngPrimeKey As Long

If Me.Dirty Then
lngPrimeKey = Me.Recordset![PrimeKey]
Me.Requery
With Me.RecordsetClone
.FindFirst "[PrimeKey] = " & lngPrimeKey
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
End If

Docmd.OpenForm "TheOtherForm",...
--
Dave Hargis, Microsoft Access MVP


"4charity" wrote:

I have done this before, without using any coding (just the property sheet in
Access), but can't remember how to do it. Hope someone can help.

I have two forms linked. I have a main form, with a button on it to the
second form. I used the Wizard so that only the related records on the second
form show up. That works fine. Here's my problem: If I am creating a brand
new customer on my main form, and click on the button to enter related data
on the second form, the info does not show up. I have running off of a query
with the Key field joined, so that's where the problem is.... it doesn't
exist in the second form yet, so the record is not in the query. I know there
is another, easy way to do this.
?????
Thanks.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:00 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.