Open form based on combo box value w/error message for blank combo box

I am working in an Access 2000 database that I've inherited.  I'm
trying to clean up some of the non-working functions.

I am trying to open a form using the OnClick property for a button. On
a job order form, there is an unbound combo box [CmbContactID] that
gets its list from querying Table!ContactInformation.[CustomerCodes].
When populated, [CmbContactID] should provide the value to open
FrmContactInformation when [CmdOpenContactForm] (a button) is clicked.
I want an error message to display if the field is blank otherwise it
will open the form for the customer code that is displayed in the
box.


I have written a macro that
1)	Checks [CmbContactID] for an entry and displays a message box
prompting the user to make a selection if the field is null
2)	If null, it returns focus to the CmbContactID control
3)	Stops the macro if CmbContactID is blank
4)	Opens FrmContactInformation based on the value in CmbContactID

Everything works fine until step 4. If I put the condition in the
Condition field of the build grid (View, Conditions) I get an error
message, "OCCDB can't find the form 'FrmContactInformation' referred
to in a macro expression or Visual Basic code." When I put the
condition in the Where Condition field in the properties area for that
particular line of the macro, it seems to totally ignore the condition
and opens a new form (filtered so that you can't search for the
appropriate contact information).

If I use the wizard to create the button, it opens the Contact
Information Form just fine-if there is a value in the field.
Otherwise, I get the same behavior as step 4 above-- the form opens to
a new record and you can't search because it's a filtered view.

Here's what the code looks like for the wizard button:
Private Sub btnContact_Click()
On Error GoTo Err_ btnContact _Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "FrmContactInformation"

    stLinkCriteria = "[CustomerCodes]=" & "'" & Me![CmbContactID] &
"'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_ btnContact _Click:
    Exit Sub

Err_ btnContact _Click:
    MsgBox Err.Description
    Resume Exit_Command250_Click

End Sub

Converting the macro to a module produced this code (but I can't
figure out how to access it from the button-and it doesn't work 100%
anyway...):

Function mcrOpenContacts()
On Error GoTo mcrOpenContacts_Err

    If (Eval("[Forms]![FrmJobEntry]![CmbContactID] Is Null")) Then
        Beep
        MsgBox "You must select a company first. Try again!",
vbInformation, "Select a company"
    End If
    If (Eval("[Forms]![FrmJobEntry]![CmbContactID] Is Null")) Then
        DoCmd.GoToControl "CmbContactID"
    End If
    If (Eval("[Forms]![FrmJobEntry]![CmbContactID] Is Null")) Then
        Exit Function
    End If
    DoCmd.OpenForm "FrmContactInformation", acNormal, "",
"[CustomerCodes]=[CmbContactID]", acEdit, acNormal


mcrOpenContacts_Exit:
    Exit Function

mcrOpenContacts_Err:
    MsgBox Error$
    Resume mcrOpenContacts_Exit

End Function

I need to incorporate the working parts of both options into one
button click solution. Can anyone help?

Thanks!

0
Ruth
4/20/2007 10:00:06 PM
access 16762 articles. 3 followers. Follow

0 Replies
947 Views

Similar Articles

[PageSpeed] 21

Reply:

Similar Artilces:

code to allow edits in form AND subform
Ok, here goes............. I have a form (frmBOL) which contains a subform (sfrmData). I have this code working to allow the form to be edited, but I can't seem to incorporate the subform into it. Everything I try gives me an error. Can anyone help? Private Sub cmdOK_Click() Dim sPassword As String sPassword = Nz(Me.txtPassword.Value, "") ' if it is a valid password, we let them edit the ' form that called this form. The calling form is ' responsible for check that the current user is ' either the QA tech on the record, or a me...

when i open an attachment it just shows a box i cannot open
Attachment, whether docs or pictures won't open. I can preview them inside the window pane, but then have to copy to word doc to print. Should be able to open attachment and then print just from there. Please help. It's like the Microsoft Picture manager is working strangely. ...

POP
Hello all, we have an issue where a PO was created with 4 line items and line item number 1 was not adding into the total on the report not the form which we did not know at the time.. then we had to edit line line 2 which at that time they noticed that the report was short still the line item #1 but the PO entry form showed the correct amount... I look into the tables and all seemed to be correct so it's just the report itself that is showing the incorrect amount.... any help would be great Hi Bam. See if the report itself has been customized. If it is, it could be a bug on the c...

Outlook2003
-----Original Message----- From: VELMURUGAN A. Sent: Wednesday, September 08, 2004 12:10 PM To: 'Microsoft Asia Pacific Support' Subject: RE: Regarding Case Number SRZ040831000874 Importance: High One more problem i.e., We are using Windows 2003/Office2003 in our entire office which is having 100+ machines and all are having standard configuration/settings. In this connection intermittently/suddently while working with Outlook2003 , it goes to Work Off-Line and ask for the domain login/password. When we enter the password, it doesn't take forward and after three attempts &...

Skip Records in a Form
I have a form in my database based on a table. The table is appended with new reocrds everyday. My goal is to have the form present only the new records and allow a user to key data into the new record and be recorded in the same table. The issue I have is that the form is displaying all records not just the new. Does anyone know a way to open a form and display only those records that have not been updated by the user? Thanks in advance Add a column for UpdateDate and update this column whenever a record is updated via the form. Set up a query to read all the rows/columns ...

Combo Box #10
Can someone give me a lame, dummy version on how to create a combo box in a cell that has a list and shows the answer selected at the top? I also need my formulas to be able to count how many times a given answer was chosen in the box. If not, that's ok. Brandy: Both of the questions you're asking are pretty straightforward. Here goes: 1) The combo box. First thing is to choose a range ON THE SAME WORKSHEET that contains the values you want for your combo box. 2) Once you have those cells filled out, go to the first cell where you want to have the combo box. 3) Go to yo...

How do I get my MS Pub 2000 to open Pub files from Pub 2003?
i cannot get my Publisher 2000 to open files from Pub 2003....do i have to buy Pub 2003? or is there a solution that I can download? I have already disabled my antivirus and that didn't do anything.. also my files are not "read only". pls help. thx. Novice Novice <Novice@discussions.microsoft.com> was very recently heard to utter: > i cannot get my Publisher 2000 to open files from Pub 2003....do i > have to buy Pub 2003? or is there a solution that I can download? I > have already disabled my antivirus and that didn't do anything.. also > my files ...

Opening a paramater form when open a report
I have a repor that takes date parameters from a seperate form.. As it is now I have to open the form put in the paramaters and then run the report which is based on a query... I would like to have the form pop up when I open the report and then close once once the report has run.. Help Please And thanks in advance bob On Wed, 15 Aug 2007 11:56:00 -0700, Bob wrote: > I have a repor that takes date parameters from a seperate form.. As it is now > I have to open the form put in the paramaters and then run the report which > is based on a query... > > I would like to ...

Checkbox in List Box
I am wondering if it is possible to have a checkbox show up in a listbox based on the value returned in one of the columns? On May 24, 12:27 am, Klatuu <Kla...@discussions.microsoft.com> wrote: > no > -- > Dave Hargis, Microsoft Access MVP > > "Rockn" wrote: > > I am wondering if it is possible to have a checkbox show up in a listbox > > based on the value returned in one of the columns? If you want to do it, you have to insert a subform in your form and that should be in datasheet view, then you can enable users to check or uncheck values or to...

Publisher 2000
After I open the Publisher 2000 program and attempt to open a file or create a new document, I get the message "Microsoft Publisher 2000 Version 6.0 has encoountered a problem and needs to close. WE are sorry for the inconvenience". I tried repairing the program and even reinstalling it, but that did not correct it. Suggestions? If you are trying to use Publisher on a network - don't it is not intended for a network Publisher files have to be worked on and saved to the local hard drive ONLY. -- Hi tom (tevanz@bellsouth.net), in the Microsoft� newsgroups you posted: ...

Rebelious Text Box
I have a text box on a form, that its control source is a memo field. I have the Verticle scroll bar selected in the properties, but it still wont become scrollable when the text in the field is more than the view of the text box. How do I spank this box into shape (in other words, what am I missing)? Make sure the internal margins are set to zero. Unless you are using Access 2007, your version may not handle the scrollbars correctly if the internal margins are set. -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply ...

opening links in outlook
why i can not open links attached to my e-mails mike wrote: >why i can not open links attached to my e-mails > I think you did some mistake in typing so just do one thing first type the link in notepad and then direct copy and paste that in your mail. -- Stellar Information Systems Ltd. D18, Sector-33, Infocity Phase II, Gurgaon-122001 Phone : (0124) 326 6069, 432 6700 Website : http://www.stellarinfo.co.in/ What happens when you try? Do you get the error; "This operation has been cancelled due to restrictions in effect on this computer" See http://www.m...

Problem trying to open old money file
Hi, I am trying to open a four-month old money file, which was on my backup disk. It is a *.mny file, not a backup file. It was created using the same version of Money (2005) which I still use. When I start MS MONEY and try open my old data file, it tells my that it wants convert my file so it works with this version. (Not sure why as the file was created in this version of MS Money). Then when I try and carry out the conversion it gives the following error message. "Money cannot locate xxxx or cannot open it, possibly because it is a read-only file or you do not have...

Running Virus Scan Slowing down opening files
3 minutes to open files in excel and word Are you using kaspersky virusscan? It is know for it. If yes please ask you administrator to exclude scan on harddisk or network files in the settings. -- Arien ------------------------------------------------------------------------ Arien's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1892 View this thread: http://www.excelforum.com/showthread.php?threadid=390878 All Virus Scanning can be stopped: If your using Norton Follow the below if you want to open documents much faster Open Norton Click on: Norton Interne...

what is error 0x8004010F
alextrio <alextrio@discussions.microsoft.com> wrote: Google is your friend. -- Brian Tillman Use Google - it returns about 755 links regarding this error. "alextrio" <alextrio@discussions.microsoft.com> wrote in message news:6FE9089D-9808-4B32-A496-B6756C9ED1D8@microsoft.com... > ...

Email with tiny attachments open slow
Good Day All, I am using Exchange server 200 and Outlook 2003 mail client. I have started to experience with a single machine where all of a sudden reading emails with attachments of any size, even 6k, slows greatly. Just selecting the email item in the list takes at least 30 seconds before the lower pane shows the body of the selected item. No other client has the same problem even while this machine does. The problem seems to disappear at some point and then returns. The machine was connected to a 10Mbps switch so I changed to a 100Mbps switch and Event logs reveal nothing. I have ...

Error on simple VBA code
I am trying to set the post to GL flag as checked on inventory batch window. The code is very simple: Private Sub BatchID_Changed() Me.PosttoGeneralLedger = 1 End Sub I tried this same code with different events but the error is the same. The error I am getting is Run time error 1007. Unsafe operation. An attempt was made to set a value which violates the application's business logic. What could be the issue here and how can I resolve it. Thank you. KT: The problem here is that a bunch of nested code runs behind the BATCHID button change event. I scripted it so you can see: *****...

Need an open house sign in sheet
Need an open house sign in sheet That's interesting, but do you have a question about Publisher? -- James Bart: "According to creationism, there were no cavemen." Homer: "Well good riddance, their drawings sucked and they all looked like hippies!" "soozeeque" <soozeeque@discussions.microsoft.com> wrote in message news:1096B15B-9766-4573-9FC2-2053BEC1F34B@microsoft.com... > Need an open house sign in sheet I would suggest keeping it simple. Use a table for the visitors' information and maybe your real estate company's logo...

Table to form
I have a field in a table called ID. 4 posititions. I have a field in a subform where I want to enter an ID. If the ID is not in the table, I want to know. How can I connect them? By the way, if it is not in the table, I would want a message to pop up or the ability to add to the table on the fly. Thanks. On Fri, 29 Jun 2007 10:36:25 -0500, "rob peterson" <buster@owc.net> wrote: >I have a field in a table called ID. 4 posititions. What do you mean by "positions"?? >I have a field in a subform where I want to enter an ID. If the ID is not in >the tabl...

cannot open excel file from outlook
Excel 2007 cannot open document eithout first saving and opening thru excel Try to re-register Excel. Close Excel first and On the Windows Taskbar Start>Run "excel.exe /regserver"(no quotes)>OK. See the space between exe and /regserver You might have to designate a full path to excel.exe. In that case Start>Run "C:\yourpath\excel.exe" /regserver(quotes required)>OK Gord Dibben MS Excel MVP On Wed, 27 Jan 2010 11:38:12 -0800, Rick <Rick@discussions.microsoft.com> wrote: >Excel 2007 cannot open document eithout first savi...

opening links
Whenever I try to open a link in Outlook XP -- (Win XP Pro) it opens a "open with" prompt/box. Point it to the .exe for your preferred browser and click okay. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the Swen virus, all e-mails sent to my actual account will be deleted w/out reading. After searching google.groups.com and finding no answer anonymous@discussions.microsoft.com <anonymous@discussions.microsoft.com> asked: | Whenever I try to open a link in Outlook XP -- (Win XP | Pro) it opens a "open with&quo...

unable to open your default mail folders...
I am running XP Pro and Office XP 2002. I currently use Outlook express on this PC but want to switch over to Outlook. When I try to open Outlook I get the message- Unable to open your default mail folders. Could not open item. Try again. Any ideas what's going on ??? Thanks in advance!!! -- Dennis Have you created a mail profile and installed your mail account(s)? -- Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. ALWAYS post your Outlook version. How to ask a question: http://support.microsoft.com/KB/555375 After furious head scrat...

Exchange Public Folders W/OUT CLASSIC?
This is a multi-part message in MIME format. ------=_NextPart_000_0019_01C3D9EE.0890D860 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I keep hearing that there is a new version of Mac Office coming out that = will run on OS X and have full native support for Exchange Public folder = use in outlook...Any word on this? --=20 Scott McDonald ------=_NextPart_000_0019_01C3D9EE.0890D860 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tr...

Workbook always opens at a specific sheet and cell
I have a workbook consisting of many sheets. How do I make sure that everytime I open the work book, it would directly point to a specific sheet and cell? Hi put the following code in your workbook module (not in a standard module). sub workbook_open() me.worksheets("sheetx").activate end sub -- Regards Frank Kabel Frankfurt, Germany Zee wrote: > I have a workbook consisting of many sheets. How do I make sure that > everytime I open the work book, it would directly point to a specific > sheet and cell? methinks the original poster also wanted to activate a particu...

Error while import BCM Database into CRM 3.0
I am trying to import BCM Database into CRM 3.0 When I run " Data Migration for Microsoft Outlook Business Contact Manager" wizard I get an unexpected error. Can someone help ? thanks Here is the Log: 8/21/2007 5:15:38 PM------>Transitioning to next screen. From: Welcome screen. To: PreconditionCheck screen. 8/21/2007 5:15:38 PM------>Connecting to Microsoft CRM Shamir_Systems_MSCRM 8/21/2007 5:15:39 PM------>Checking that Microsoft CRM Data Migration Pack is installed: Success 8/21/2007 5:15:39 PM------>Establishing connection to CDF database: Success 8/21/2007 5:1...