Continuous form / new record

Hi all, I have the following issue..

In a continuous form, for each new record, I have a command button that 
“creates” a related record...this command button is visible in the “next 
record” even if a record is not created in the current form. How do I 
restrict the command button from creating a new related record if the current 
record is not created..?

I hope I managed to explain my problem well...

Thanks!

0
Utf
1/21/2010 7:19:02 AM
access.formscoding 7493 articles. 0 followers. Follow

4 Replies
817 Views

Similar Articles

[PageSpeed] 43

On Wed, 20 Jan 2010 23:19:02 -0800, Peter
<Peter@discussions.microsoft.com> wrote:

If you setup your db design correctly, the related (child) record
CANNOT be created until the parent record is created. Enforcing this
"referential integrity" is one of the cornerstones of a relational
database. Open the Relationships form, put both tables on it, draw a
line from the PK to the FK, and check the box to enforce the relation.

With that out of the way, you can test for Me.NewRecord to know if
you're on a new (not yet saved) record:
if Me.NewRecord then
  Msgbox "Yo! Don't click me until a parent record exists"
else
  'Code to create child record goes here.
end if

-Tom.
Microsoft Access MVP



>Hi all, I have the following issue..
>
>In a continuous form, for each new record, I have a command button that 
>�creates� a related record...this command button is visible in the �next 
>record� even if a record is not created in the current form. How do I 
>restrict the command button from creating a new related record if the current 
>record is not created..?
>
>I hope I managed to explain my problem well...
>
>Thanks!
0
Tom
1/21/2010 1:44:38 PM
I'm not sure I completely understand, but maybe one of these two things will 
help...

If you are trying to show a button visible only on a new record, scratch 
that idea.  Continuous forms don't allow for any "differences" (other than 
data obviously) for each record.

If you want the button only to show when there is a previous record to copy 
from (in the same form), then you can check the RecordCount property of the 
Form's Recordset...

If Me.Recordset.RecordCount = 0 Then Me.MyButton.Visible = False
(or, if you like...)
Me.MyButton.Visible = Me.Recordset.Recordcount


If, by chance, you are creating a record in a continuous form that is a 
subform and you mean "related" record by a record on the Main form, then 
there may be a way to handle this as well.  In your continous form, save your 
form with the button visible property set to false... then, in the Current 
and AfterUpdate events of the Main form, use some code to toggle the 
visibility of the button...

If Me.NewRecord Then
  Me.SubformControl.Form.MyButton.Visible = False
Else
  Me.SubformControl.Form.MyButton.Visible = True
End If

I should note though, that copying "related" information to a subform (if 
this happens to be the case) is probably a bad practice.    It sounds like 
maybe you're entering the same data twice (main and sub).  There are some 
cases (say an item master, to which you create an order that may have a few 
differences) where this is ok, but mostly you want to avoid it.

Anyway, not sure exactly what the situation is, but maybe something I've 
said will give you an idea or two...

hth

-- 
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."  
-Thomas Edison (1847-1931) 



"Peter" wrote:

> Hi all, I have the following issue..
> 
> In a continuous form, for each new record, I have a command button that 
> “creates” a related record...this command button is visible in the “next 
> record” even if a record is not created in the current form. How do I 
> restrict the command button from creating a new related record if the current 
> record is not created..?
> 
> I hope I managed to explain my problem well...
> 
> Thanks!
> 
0
Utf
1/21/2010 5:01:02 PM
I'm not sure I completely understand, but maybe one of these two things will 
help...

If you are trying to show a button visible only on a new record, scratch 
that idea.  Continuous forms don't allow for any "differences" (other than 
data obviously) for each record.

If you want the button only to show when there is a previous record to copy 
from (in the same form), then you can check the RecordCount property of the 
Form's Recordset...

If Me.Recordset.RecordCount = 0 Then Me.MyButton.Visible = False
(or, if you like...)
Me.MyButton.Visible = Me.Recordset.Recordcount


If, by chance, you are creating a record in a continuous form that is a 
subform and you mean "related" record by a record on the Main form, then 
there may be a way to handle this as well.  In your continous form, save your 
form with the button visible property set to false... then, in the Current 
and AfterUpdate events of the Main form, use some code to toggle the 
visibility of the button...

If Me.NewRecord Then
  Me.SubformControl.Form.MyButton.Visible = False
Else
  Me.SubformControl.Form.MyButton.Visible = True
End If

I should note though, that copying "related" information to a subform (if 
this happens to be the case) is probably a bad practice.    It sounds like 
maybe you're entering the same data twice (main and sub).  There are some 
cases (say an item master, to which you create an order that may have a few 
differences) where this is ok, but mostly you want to avoid it.

Anyway, not sure exactly what the situation is, but maybe something I've 
said will give you an idea or two...

hth

-- 
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."  
-Thomas Edison (1847-1931) 



"Peter" wrote:

> Hi all, I have the following issue..
> 
> In a continuous form, for each new record, I have a command button that 
> “creates” a related record...this command button is visible in the “next 
> record” even if a record is not created in the current form. How do I 
> restrict the command button from creating a new related record if the current 
> record is not created..?
> 
> I hope I managed to explain my problem well...
> 
> Thanks!
> 
0
Utf
1/21/2010 5:17:01 PM
In button click event, insert a check:
If Me!NewRecord Then
   Exit Sub
End If
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they 
eat for a lifetime".


"Peter" wrote:

> Hi all, I have the following issue..
> 
> In a continuous form, for each new record, I have a command button that 
> “creates” a related record...this command button is visible in the “next 
> record” even if a record is not created in the current form. How do I 
> restrict the command button from creating a new related record if the current 
> record is not created..?
> 
> I hope I managed to explain my problem well...
> 
> Thanks!
> 
0
Utf
1/21/2010 6:44:01 PM
Reply:

Similar Artilces:

Publisher will not recognize new printer
I just replaced my Brother MFC model 7150 with a new Brother MFC model 210C. The printer will function with all the features of Office 2003 except Publisher. Every time I select print or print preview, I receive a message that a printer has not been installed on the system. I asks that I install a printer for Publisher use. My old Brother worked fine with the Publisher program. What can I do to make Publisher recognize the new printer?? Did you completely remove all traces of your old printer? How to clean up printer drivers http://members.shaw.ca/bsanders/CleanPrinterDrivers.htm When y...

Merging List w/ a Form
Can anyone assist me with merging a form created in Excel with a database (or list) also created in Excel? I know how to merge an Excel worksheet to be used as a database for Word in the Mail Merge command, but my FORM, with which I am trying to merge my database, was created in Excel and needs to remain under its format (not be converted to Word). I am filtering the information I need from the database to be imported to the Excel Form. Any help would be appreciated. Thank-you. If you're trying to display information from one record in the database, there are sample files here...

Adding new rows
I have a spreadsheet with 100 rows in, I need to add a row after each current row, is there a quick way to do this or have i got to insert each new row individually? -- Paul Sheppard ------------------------------------------------------------------------ Paul Sheppard's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=24783 View this thread: http://www.excelforum.com/showthread.php?threadid=390760 I assume you want to add an empty new row in between the existing rows. One way would be with an extra column Save as "trial" first.......just in case thi...

I would like to design a logo for a new superstore
I just can't seem to get an inspiration to design a logo to use for this superstore. Even coming up with a name seems to be a difficult task. Inspiration here, over 7,000,000 hits http://images.google.com/images?q=logo&hl=en -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com http://officebeta.iponet.net/en-us/publisher/FX100649111033.aspx "tinard" <tinard@discussions.microsoft.com> wrote in message news:CE8F1689-4D1A-401C-BE11-2F2DB3CF34A6@microsoft.com... >I just can't seem to get an inspiration to desig...

synchronizing new e-mail ( headers only option)
Hello. there is an option to synchronize mail full message or header only or new message in outlook express. I just want to synchronize Headers of new e-mail only wheni check for new e-mail..( you know there is so much spam now ad ays..i just do't want to open any new e-mail in my e-mail inbox until i know it is not spam...) please reply with a solution. Thanks. rao You can use an IMAP account in OE to accomplish this. Please note, This newsgroup is for support of Outlook 97, 98, 2000 & 2002 from the Office family for Windows PCs. For Outlook Express (OE) support try posting...

User able to see records that he is not supposed to
Hi, I have a user having a role that has permission to read only records that are created by him. He is able to see records that are assigned to a team X. He is not a member of team X. I have no clue how he is able to see it. I have checked every setting very carefully.Please help. IS IT a Microsoft CRM BUG??? Cheers, kunal Hi, Kunal, Can you please provide the specific settings of the security role(s) assigned to the user? Thanks, Leslie -- This posting is provided "AS IS" with no warranties, and confers no rights. Please do not send e-mail directly to this alias. This ...

Moving my files to a new computer
So I've copied my old .pst file to my new computer, used Tools>options>mail setup>data files to introduce outlook to it, and reset it to to default and removed the old entry so there is just the one entry in the list. Both my new and old outlooks are 2003. So far so good and I can see my mail folders and contacts in the left hand pane, *but* tools>address book is not showing any of my contact addresses, nor will check names show them. Anyone know whay or can point me at an article that tells me what to do? Also, I have several email accounts is there an easy way of movi...

Tabbing into continuous subform ignores the first control
When I tab into the subform, from the last position in the main form, the focus moves to the second control in the continuous subform except on the first record entered in a session. I shift+tab back to the first control and the tabbing is normal from then on until the next record gets to the subform. The order of the controls on the subform is the same as the fields in the underlying table and the effect is the same in Datasheet view (of the subform). This first control on the subform is a combo box if that effects anything. Is there a way to get the tabbing right? ern. No, I thought the...

How to display mfc control in new look style?
Hi, anybody knows how to show mfc controls like button or other controls in new look style? Please see below link to know about what i mean by new look style is. http://www.geocities.com/henky_arektc97/question/ I want to make my controls in dialog shown as Picture 2, not as Picture 1 (look at the button). Are there lack of some defines or codes or something else, because when I create new project again, the dialog will be displayed as I want in Picture 2. I use MFC 9 (vs2008). Thank you for any help! "Saitama" <Saitama@discussions.microsoft.com> wrote in message ne...

CRM 1.2
I am going to move the CRM SQL databases to a new server. We will also be moving Great Plains off the CRM server and on to the new SQL server. We are bouncing around the idea of naming the new SQL server to the name that the current CRM server uses and renaming the current CRM server. The thinking here is that we won't have to touch the Great Plains clients. What kinds of issues can I expect in this scenario? I believe that CRM "might" make us of the SID in which case I would need to use SysPrep to create the new one? I wouldn't think that this is that unusal of a proje...

New version of RMS
I received a call from Microsoft yesterday wanting me to go ahead and extend my support for RMS which still isn't due for a couple of months and that makes me really angry that they are so fast to want my support extended. It's a little hard for me to consider extending my support with Microsoft when I have yet to receive an upgrade to RMS for yet another year and at this point I have had this version installed so long I no longer have had a need to make a support call for over a year. I have no idea if I will see a new release even in the next year because apparently it is so...

Prinding each row of Excel sheet on a seperate page dispallying one record on each pa
From a spread sheet ,I need to print out a row on each page seperately that is printout each record on the row on one page seperately. Can any one please advise how it can be done ? Fro example Row 1 Data 11 Data 12 Data 13 Row 2 Data 21 Data 22 Data 23 Row 3 Data 31 Data 32 Data 33 I would want to print out Data 11 and Data 22 on one page then Data 21 and Data 22 on the second page and data 31 and Data 33 on the third page Pleae advise if and hwo this is possible. Thank you Sanjeev --- Message posted from http://www.ExcelForum.com/ Sorry ...

NEW LAPTOPS & LCD's CAN HAVE A BAD REFLECTION PROBLEM
Since a couple years ago, there're 2 types of LCD coatings. Many new consumer laptops come with "BriteView" (also known as "Glossy") which makes them look STUNNING shiny - an eye candy as long as you see it in a store. But when you use for professional purposes you'll find reflections can offset the benefit of "BriteView's "looking cool" The traditional coating until "BriteView" was forced upon us, was "Antiglare" (also known as "Matte"), the good news they both co-exist. Which oen you prefer is a matt...

Filter Report by Form
I'm using the following code from the wonderful Allen Browne which works perfectly in an either or scenario (either by Start/End Date(s) OR filtering by client name; but I don't know what syntax to use to filter by Start/End date(s) AND anything typed in the client name field. I'm sure it's easy but I can't get my head around it. I appreciate any and all assistance!! Private Sub cmdPreview_Click() 'On Error GoTo Err_Handler 'Remove the single quote from start of this line once you have it working. 'Purpose: Filter a report to a date r...

Record Change Confirmation
This is a multi-part message in MIME format. ------=_NextPart_000_0081_01CAB184.C1BB7DD0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Access 2007 sp2 I'm using the following code I found on the web, on a Single Form, to = have the user choose to either save the record or not save the record or close the message box and continue editing: Private Sub cmdSaveAndClose_Click() If Me.Dirty Then Dim BlnOutcome As Integer BlnOutcome =3D MsgBox("Record(s) have been added or changed." _ ...

Button on Form to Run Report based on Query with Parameters
Hi Guys. I am busy working on a stock control database (and job control). When I have a Form Open, it shows several fields, including JobID (Which is the PK for that job) (frm_Invoicing) I also have a Query that when Run, it prompts for the JobIDNo. (qry_CustJobsInvStock) I have a report based on that query. (rpt_CustJobsInvStock) I have added a button onto the form (onclick -> DoCmd.OpenReport) to open and automatically print the report, But I just cannot figure out how to get it to get my JobID from the form, and to Automatically add it as a Parameter for the que...

Template driver code for a new USB Touchscreen XP driver
We want to develop a new Touchscreen driver having a USB interface for Windows XP. Which driver template will be the most suitable to start the development ? make your device a HID and then you not have to write a driver at all. d -- This posting is provided "AS IS" with no warranties, and confers no rights. "sanju_emb" <sanju_emb@discussions.microsoft.com> wrote in message news:E8AAAA05-B6EA-44A7-B9E8-20E5F0A5860C@microsoft.com... > We want to develop a new Touchscreen driver having a USB interface for > Windows XP. Which driver te...

Center Access2007 Form in the middle of access Main Window
Thank You Is there any easy way to center access 2007 forms in the middle of the screen (Monitor) or access main window. and give me good result Hello, I think there is no built in feature to achieve this goal. You may need to create a new form and configure it as the main window. You could enumerate forms and create buttons etc to open forms from this main form. For example, you could use hte following code enumerate forms in your database: Dim db As Database Set db = CurrentDb Set cntContainer = db.Containers("Forms") For Each doc In cntContainer.Documents Str...

Formula to reference another worksheet, locate data, then record i
Hi All, It has been over 10 years since I did my Excel studies and I've unfortunately forgotten everything I haven't used regularly. My office has recently upgraded to Office 2007 (upgrade not being the descriptor I'd have chosen!) and I'm struggling with Excel. I've found my way around most issues, but I'm REALLY stuck now and suffering Friday-itis on top of it all! Essentially I have a multi-sheet workbook for my debtors ledger. Each page has separate columns for the customer numbers, names, total debts in each age range (7 days, 14 days etc), totals and lastl...

New-systemmessage
Hi all, I am trying to customize a few of the Exchange 2007 system message. I have been able to change a system message so that if users send to an invalid address at our domain, the messages replies that the address doesn't exist on our company's mail server. I am trying to customize the message so that if a user sends to a non-existent domain. Currently they get this: "A problem occurred during the delivery of this message. Microsoft Exchange will not try to redeliver this message for you. Please try resending this message later, or provide the following d...

Comparing records in 2 databases
I need to update an access database each day, with stock and price info, and then update it online. Is there a way to compare the before and after tables, and make a new table with only the changed records (only the changed fields!) plus the primary key? OR, does anyone know of a fairly inexpensive program that will do this? For Access 2k. Thanks! Tracking date record was created or updated, SQL Syntax --- It is a good idea to add these 2 fields to all your tables (except lookups). Let them be the last 2 fields. DateCreated, date, DefaultValue = Now() DateModified, date � set on...

Printout Method
In building a form to allow users to print a "blank form" I've constructed as an Access Report, I'd like the user to be able to select the number of copies to print. It looks like the PrintOut Method would be a good choice for this, but I'm not smart enough to know quite how to get the "Copies" argument to get its input from the textbox on my form, where the user will enter the number of copies they'd like to print. Suggestions? -- Thanks, Croy Does the report have a record source? -- Duane Hookom Microsoft Access MVP If I have helped you, please help...

Customize global adress list column in a new mail
Hi! (I have Outlook 2007 and Exchange 2007). when i create a new mail message, hit the "To" button, my global adress list window appear when column by default: Name, Title, business Phone, Location, E-mail address, Company and Alias. Those column from Active directory of course. My question is: can I add/remove column in this window? For example adding "department" from Active directory? thx Since this is customized by your Exchange Admin, I would start by asking him/her if it is possible. This question can most likely be answered in an Exchange or W...

How do I activate the new mail button
When I start Outlook, the "New", "forward", "reply" and "reply to all" buttons are not active which means I can not send mail. I have no problems receiving mail. Also, on web pages with email links, when I click on them, the Outlook application is not launched which is almost certainly related to this. I think I'm missing something very simple here! Are you in a mail enabled folder? Do you have an active email account installed? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert...

Reactivating Office on a new computer.
I had a downloaded copy of Office 2007 on a laptop which has been destroyed beyond repair. I have now bought a new laptop. How do I re-download my copy of Office, please? -- Steve Contact the vendor from where you purchased it. "stemac" <stemac@discussions.microsoft.com> wrote in message news:795E14D0-A5F1-4CA4-B2B4-A102986CBADD@microsoft.com... :I had a downloaded copy of Office 2007 on a laptop which has been destroyed : beyond repair. I have now bought a new laptop. How do I re-download my copy : of Office, please? : -- : Steve The vendor was...