How to make a Add key disabled after adding one record unless

Hi,
I have a form where I am adding records. There are two boxes where one has 
to put the lineitemnumber and another box where one has to put the 
description. Unless the above two boxes are filled in the Add command box 
need to be disabled. Now, the problem is after adding one record the Add 
button is enabled and I cannot disable it. I would appreciate any help to 
solve this. 
The error message is:
The methos is not supported
The following is the code:
Private Sub cmdadd_Click()

On Error GoTo Err_cmdadd_Click
    If (IsNull(Me.LineItemID) = True) Or (IsNull(Me.Description) = True) Then
      MsgBox ("You cannot save null values to the system")
    End If
    Dim db As Database
    Dim rstApp As Recordset

    Dim strSQL As String
    Dim strLineItemID As String

    Set db = CurrentDb
    Set rstApp = db.OpenRecordset("tblLineItems", dbOpenDynaset)
    strLineItemID = Trim(Me.LineItemID)
    
    If MsgBox("OK to Add " & strLineItemID & " ?", vbYesNo, "Confirm Add") = 
vbYes Then
        With rstApp
            .AddNew
            !LineItemID = Me.LineItemID
            !Description = Me.Description
          strSQL = "SELECT [tblLineItems].[LineItemID], 
[tblLineItems].[Description] FROM tblLineItems order by tblLineItems"
            
            .Update
            MsgBox ("Records added to system")
        End With
        
    Else
        MsgBox "Add Cancelled"
    End If
    Forms![frmAddLineItems]![LineItemID] = ""
    Forms![frmAddLineItems]![Description] = ""
    Me!LineItemID.SetFocus = True
    Me!cmdadd.Enabled = False
    Exit Sub
Exit_cmdadd_Click:
    Exit Sub
Err_cmdadd_Click:
    MsgBox Err.Description
    Resume Exit_cmdadd_Click
    
End Sub

0
Utf
7/5/2007 9:40:05 PM
access.formscoding 7493 articles. 0 followers. Follow

1 Replies
758 Views

Similar Articles

[PageSpeed] 54

"Jack" <Jack@discussions.microsoft.com> wrote in message 
news:2A3C6DBE-6133-43F1-8181-D03A208ED400@microsoft.com...
> Hi,
> I have a form where I am adding records. There are two boxes where one has
> to put the lineitemnumber and another box where one has to put the
> description. Unless the above two boxes are filled in the Add command box
> need to be disabled. Now, the problem is after adding one record the Add
> button is enabled and I cannot disable it. I would appreciate any help to
> solve this.
> The error message is:
> The methos is not supported
> The following is the code:
> Private Sub cmdadd_Click()
>
> On Error GoTo Err_cmdadd_Click
>    If (IsNull(Me.LineItemID) = True) Or (IsNull(Me.Description) = True) 
> Then
>      MsgBox ("You cannot save null values to the system")
>    End If
>    Dim db As Database
>    Dim rstApp As Recordset
>
>    Dim strSQL As String
>    Dim strLineItemID As String
>
>    Set db = CurrentDb
>    Set rstApp = db.OpenRecordset("tblLineItems", dbOpenDynaset)
>    strLineItemID = Trim(Me.LineItemID)
>
>    If MsgBox("OK to Add " & strLineItemID & " ?", vbYesNo, "Confirm Add") 
> =
> vbYes Then
>        With rstApp
>            .AddNew
>            !LineItemID = Me.LineItemID
>            !Description = Me.Description
>          strSQL = "SELECT [tblLineItems].[LineItemID],
> [tblLineItems].[Description] FROM tblLineItems order by tblLineItems"
>
>            .Update
>            MsgBox ("Records added to system")
>        End With
>
>    Else
>        MsgBox "Add Cancelled"
>    End If
>    Forms![frmAddLineItems]![LineItemID] = ""
>    Forms![frmAddLineItems]![Description] = ""
>    Me!LineItemID.SetFocus = True
>    Me!cmdadd.Enabled = False
>    Exit Sub
> Exit_cmdadd_Click:
>    Exit Sub
> Err_cmdadd_Click:
>    MsgBox Err.Description
>    Resume Exit_cmdadd_Click
>
> End Sub
>

The easiest way for me has been to check for values in both fields in each 
field's AfterUpdate event, and if both are non-Null enable the button. The 
error you're getting is probably caused by the fact that you can't disable a 
command button while it has focus, and the button has focus because you're 
in the button's Click event. Just shift focus to some other control, and 
then you can disable the button.

Carl Rapson


0
Carl
7/6/2007 3:19:22 PM
Reply:

Similar Artilces:

How can I disable script blocking in Outlook 2003
I am trying to use Franklin Covey's Plan Plus for Ooutlook and can not because of Outlook's internal script blocking...HELP! ...

Automatically delete messages from one's Inbox after a fixed time?
We've set up a spam quarantine mailbox in Exchange 2007. So far, false positives are pretty rare, so we'd like to set up a policy where read/unread messages automatically get removed from the mailbox after a certain time (e.g. 5 days). Is there a way to do this? Thanks. Using Managed Content Settings (roughly equivalent of Mailbox Manager in Exch2003/2000). -- Bharat Suneja MVP - Exchange www.zenprise.com NEW blog location: exchangepedia.com/blog ---------------------------------------------- "Derek" <Derek@discussions.microsoft.com> wrote in message news:711...

Looking for GPO to add Address List to Address Book for checking names in specified order
Hi, I want to deploy an extra address list to the address book of our users in Exchange/Outlook 2003. This can be done manually: open address book, select "Options" and press the buttonb "Add..." to add another Address List. Perhaps it can be done differently, but i need Outlook to lookup people in an extra address list. Who can help me deploying this? Preferably with a GPO or perhaps a logon script example? Regards, Hans. You add address list through ESM Read this article http://support.microsoft.com/Default.aspx?kbid=319213 -- Nebojsa Seslija -----------...

How to get the list of all SQL Server foreign keys in a database by using Microsoft.SqlServer.Management.Smo ?
Hello. I have found many post telling how to create a foreign key with SMO but no one explaining how to list them. Anybody knows ? Thank you, Gilbert "Gilbert Tordeur" <gilbert.tordeur@orange.fr> wrote in message news:epHLDvm1KHA.3744@TK2MSFTNGP04.phx.gbl... > Hello. > > I have found many post telling how to create a foreign key with SMO but no > one explaining how to list them. > > Anybody knows ? > > Thank you, > Gilbert > On SQL Server, it's: select * from sys.foreign_keys works for sure on SQL Serv...

adding external address in the Global Address List
Ok.. Be Gentle.. I forgot how to add someone as an external contact to Exchange 2000 that has an Earthlink.net, AOL.com,etc.. external email address. I swear I used an article from MSExchange.org last time but I can't find it now. Can someone point me in the right direction. Thanks! Kenny Kenny Simply create a contact object in AD, use an SMTP address If you wish to setup forwarding, create the contact, then setup the user account to forward to the contact. Use Store & Forward if you wish to keep a copy of messages on your server. ...

how can i add the global fields on the windows using the modifier
Hi All how can i add the global fields on the windows. Sharat Mittakola You can't. Only fields from the linked table can be added to a window. For the rest you would have to make local fields and populate it via ADO. patrick mbs dev support -- This posting is provided "AS IS" with no warranties, and confers no rights. "smittakola" <smittakola@discussions.microsoft.com> wrote in message news:2BDA6D20-A423-44DB-B2E9-CD473E1068A2@microsoft.com... > Hi All > > how can i add the global fields on the windows. > > > Sharat Mittakola ...

AD->ADAM/LDAP
Can one use just ADAM/LDAP(No ActiveDirectory dependent) connector for Exchange Server serving Outlook clients? Thanks "Simon Geary" <simon_geary@hotmail.com> wrote in message news:uVoRNAdSEHA.3988@tk2msftngp13.phx.gbl... > No, you need Active Directory for this, ADAM will not be enough. > > "Sarah Tanembaum" <sarah.tanembaum@yahoo.com> wrote in message > news:2i9poeFkbs20U1@uni-berlin.de... > > Can one use just ADAM/LDAP(No ActiveDirectory dependent) connector for > > Exchange Server serving Outlook clients? Thanks > > > >...

Add a number to a same cell
Hi, thanks for reading this. Have a problem, say in cell A1 I type a number like 500 into it, and when I hit enter I want it to add say 525 to that number and then display in in the same cell A1. Is this possible? or am I asking too much from Excel. I know I can have it display in a different cell but, this is what I want. Thanks for any help. Bobby Bobby, Only an event macro could let you type a number, and keep a running total in the same cell. There's a rash of making accumulators like that, and it's n...

Disabled account showing in GAL
Is there a way to keep a disabled account from appearing in the global address list? I don't want to delete the account for a period of time, I just don't want it active or to appear in the address book. Hi Jim, In Active Directory Users and computers turn on Advanced Features under the View menu. Then on the Exchange Advanced tab on the properties of the user you should see a check box "Hide from Address List" check this box and within about 15 - 30 min the user should disappear from the GAL. Hope this helps, -- Matthew Byrd Microsoft PSS When responding to post...

Adding an HTTP Virtual Server to an existing IIS website
Hi, I host server IIS websites using host headers to direct to the correct site. I'd like to add OWA to these sites so have tried creating a new HTTP Virtual Server in System Manager using the same name as in IIS Manager and the same host header. However, when trying to start the server, I get the error message "Cannot create a file when that file already exists". Any ideas how I can do this? J This is showing in the event logs: Cannot register the URL prefix 'http://www.domainname.net:80/' for site '100'. The necessary network binding may already be in...

Tying records
Hi I am working on an existing database. I want to create a query which pulls data from 2 child records of a parent. The first record in my query would contain information frmo the first child record along with the first child record of the other table, the second to the second, etc. Is there a way to do this? Could someone help? Thanks Jeff I am not sure I understand exactly what you are trying to receive back. Here is a method that may get you what you want depending on how your tables are related. If the child records are in the same child Table Maintable ID MainTableData ChildTabl...

How can I add a small .gif in an Excel cell?
I'm trying to add a couple of small pictures in cells, but having no luck. I want to have (for each song entry) a pdf picture that will link to a PDF file with lyrics and chords. And the same with another picture of a Word document that links to custom made lead sheets. The problem is that I can't put a picture inside a cell. This may not seem like a problem to most, but I'm using the AutoFilter function, and I want to be able to filter by whether an entry has the picture in the cell or not. If you can help me, that would be great! Thanks in advance for your time and eff...

add legend to chart
For the heaven sake, how can I add a legend to the chart without choosing different chart style?? Whenever I need to modify a chart I must choose another style then make my modifications. What on earth was wrong with the commands of excel 2003 and earlier? They were quite easy to handle. The only new thing I found in office 2007 is the innovative color and shapes systems, and the ability to see the final result before applying the change. What a big deal!!! Not to mention that there is no option to group a text box with a chart even in Word, which gives me hard times arranging my docume...

Toolbar shortcut to Add-in
Hi all Can someone please point me to a link or otherwise give me step-by-step instructions on how to create a toolbar icon shortcut to an installed add-in? Thanks -- Return email address is not as DEEP as it appears In addition to the specific query, is there a general way of creating a toolbar shortcut icon for ANY menu item? -- Return email address is not as DEEP as it appears "Jack Schitt" <mind-the-gap@DEEPblueyonder.co.uk> wrote in message news:uMeF4N%23lEHA.1356@TK2MSFTNGP09.phx.gbl... > Hi all > > Can someone please point me to a link or otherwise...

navigating with the tab key
How do I get the cursor to move to the next cell after pressing the tab key. In my case after entering data in one cell and pressing the tab key to move to the adjacent cell, the tab key takes me to the next page, causing me to navigate backwards. Is there a remedy to this, how do I limit the number of cells the tab key moves to?-- Cynthia Tools>options>transition, deselect transition navigation keys -- Regards, Peo Sjoblom "Cynthia" <cd300@yahoo.com> wrote in message news:1659D8D3-964D-41DB-8094-0D3E62D820AC@microsoft.com... > How do I get the cursor to ...

Make result "#VALUE! Clear
i have some cells that return #VALUE!. when the right info gets put in everything works fine. what i am looking for is in the mean time... until i put in the info... for it to not show #VALUE!. i have tried conditional formatting but i can't seem to get it to work. anybody know what can be done? -- thanks so much what i do in those situations is use an if statement. lets say in cell a1 i have the number 5. in cell a2 i havent anything in cell a3 i would put this =if(a2="","",if(a1="","",a2/a1)) this checks a2 first. if a2 is blank ("&...

Search emails for word "attachment" then check if there is one
The most common Outlook user error is typing a message with an alleged attachment, then forgetting the attachment! The solution is for Outlook to word search for the word "attachment" in the body of the e-mail, cross check to see if there is an attachment, then create a pop-up "Did you mean to provide an attachment?" if there is a mismatch. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the ...

Listing record counts as zero in reports
I've set up a simple database in Access 2003. It has one table with 5 fields. 1 Primary index autonumber, 1 Date field and 3 fields filled from lookup tables. I want a report that will count records in this one table and specifically for the different values of one of the fields whose three values are in a lookup table. There are several situations when the no of records for a particular value is ZERO. I still want an entry in my report, stating that the number of records with that field value is ZERO. Clearly as their are no records they are not counted and not included in the re...

How do I add multiple addresses to the "to" field without having to go back into the body each time.
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) I've just switched from Outlook to Entourage. In Outlook mail, I would open a new email, type a few letters to find the first recipient, push enter, and it would pull the address from my address book, put in a semicolin, and I could keep adding more addresses until I was finished. <br><br>With Entourage, I type a few letters, find the right address, push enter, and it puts in the addresses, but then leaves the &quot;to&quot; field and jumps to the next field (subject) in the e-mail template. To add anoth...

Cannot update locked record fields using workflow CRM 4.0
We have some form fields locked to prevent user changes. It seems in version 4.0 you can no longer access the locked fields when configuring workflow. This was not a problem in version 3.0. -- Gary Herbstman Byte Solutions, Inc. http://bytesolutions.com ------=_NextPart_0001_070B3E7E Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi Gary. Thanks for posting in. This is Ken in Online Partner Support. You are able access the locked field from workflow whereas you are not able to access read-only field from workflow. Lock feature is used to prevent from removing the attribute...

AD account locking continuously
I recently changed my AD password (10 days ago) and now my account locks 2 or 3 times a day. Mostly when I try to RDP to a server it will lock instantly. I'm wondering if anyone can point me int he direction of resolving this. I figured it was a service running under my account but I have not been able to find it. I have changed my pwd plenty int he last several months and this has never happened. Thanks for any input- Check out an article I have on "User Account Lockout" at http://www.pbbergs.com/windows/articles.htm -- Paul Bergson MVP - Directory Services ...

Can you create and send e-newsletters longer than one page?
While Publisher lets me create an e-newsletter longer than one page, it won't let me e-mail it in the body of the e-mail. I'm not looking to write a book, but three stories is a bit too limiting. Any ways to trick the technology into letting me have my way with it? http://ed.mvps.org/Static.aspx?=Publisher/multipageemail -- JoAnn Paules MVP Microsoft [Publisher] "kRo" <kRo@discussions.microsoft.com> wrote in message news:E8596441-7317-4CEF-B972-F689BEF16399@microsoft.com... > While Publisher lets me create an e-newsletter longer than one page, it > w...

Add multiple new records based on quantity duplicating data
I am creating a simple form to allow a new user to list a part number and requested quantity. Upon executing a submit button, I would need the part number value added/duplicated into an existing table as many times as the requested quantity. However, the requested quantity can not exceed 999. Simplest solution if you are familiar with code would be to OpenRecordset, and AddNew in a loop. An alternative would be to create a table containing 999 records, and use it as the source table for an Append query statement, with criteria limiting it to the desired number. This link explains how t...

one year back mails downloading now
hi, my query is in i created one user dated on 25 aug 2005 in AD,and created mailbox also and one delivery forwarding address i.e.abc@yahoo.co.in(in exchange genral that is option) now problem is that user's has yahoo id mailbox was full and yahoo people disable his yahoo account. so whenever all users forwarding mail to him that time yahoo id gets error to every one.so what i done is i remove his forwarding address i.e abc@yahoo.co.in,that chenges i done last month only,now problem is those users send him to mail last december and january mail that delivery error mail dowloading n...

add email accounts to outlook that are not msn
I have recently purchased outlook 2003 to organize my mail. I have my hotmail account set up in outlook but I would like to add my verizon email account. Is this possible since I receive the msn service through verizon? I don't see why not...get the POP3/SMTP or IMAP server names from Verizon and go ahead and set up your account. Outlook is not a client only for Microsoft's own e-mail accounts; it works with just about any ISP. -- Jocelyn Fiorello MVP - Outlook *** Messages sent to my e-mail address will NOT be answered -- please reply only to the newsgroup to preserve the...