PC Review


Reply
Thread Tools Rate Thread

Trouble with the following

 
 
Opal
Guest
Posts: n/a
 
      10th Nov 2011
Running Access 2003 and trying to open a form with the following:

If Len([cboEmployee] & "") <> 0 And IsNull(Me.FromDate) And
IsNull(Me.ToDate) Then
strWhere = "EmployeeID =" & Employee
DoCmd.OpenForm "frmReflection", , , strWhere
End If

And the form opens to a blank record when the combo box has a value.

Even this does the same thing:

If Not IsNull(me.cboEmployee And IsNull(Me.FromDate) And
IsNull(Me.ToDate) Then
strWhere = "EmployeeID =" & Employee
DoCmd.OpenForm "frmReflection", , , strWhere
End If

What am I missing... I think I have been staring at this too
long..... :-(
 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      10th Nov 2011
On Thu, 10 Nov 2011 14:02:18 -0800 (PST), Opal <(E-Mail Removed)> wrote:

>Running Access 2003 and trying to open a form with the following:
>
> If Len([cboEmployee] & "") <> 0 And IsNull(Me.FromDate) And
>IsNull(Me.ToDate) Then
> strWhere = "EmployeeID =" & Employee
> DoCmd.OpenForm "frmReflection", , , strWhere
> End If
>
>And the form opens to a blank record when the combo box has a value.
>
>Even this does the same thing:
>
> If Not IsNull(me.cboEmployee And IsNull(Me.FromDate) And
>IsNull(Me.ToDate) Then
> strWhere = "EmployeeID =" & Employee
> DoCmd.OpenForm "frmReflection", , , strWhere
> End If
>
>What am I missing... I think I have been staring at this too
>long..... :-(


What's the datatype of EmployeeID? What are the RowSource and the Bound Column
of the combo box Employee? If you put a breakpoint in your code (mouseclick
the grey bar to the left of the DoCmd.OpenForm line) what is the value of
strWhere?

My guess is that either EmployeeID is a Text field requiring quotemarks:

strWhere = "[EmployeeID] = '" & Me.Employee & "'"

or the combo box isn't returning the expected value.

--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
 
 
 
Opal
Guest
Posts: n/a
 
      11th Nov 2011
On Nov 10, 5:23*pm, John W. Vinson
<jvinson@STOP_SPAM.WysardOfInfo.com> wrote:
> On Thu, 10 Nov 2011 14:02:18 -0800 (PST), Opal <tmwel...@hotmail.com> wrote:
> >Running Access 2003 and trying to open a form with the following:

>
> > * *If Len([cboEmployee] & "") <> 0 And IsNull(Me.FromDate) And
> >IsNull(Me.ToDate) Then
> > * * * *strWhere = "EmployeeID =" & Employee
> > * * * *DoCmd.OpenForm "frmReflection", , , strWhere
> > * * * *End If

>
> >And the form opens to a blank record when the combo box has a value.

>
> >Even this does the same thing:

>
> > * *If Not IsNull(me.cboEmployee And IsNull(Me.FromDate) And
> >IsNull(Me.ToDate) Then
> > * * * *strWhere = "EmployeeID =" & Employee
> > * * * *DoCmd.OpenForm "frmReflection", , , strWhere
> > * * * *End If

>
> >What am I missing... I think I have been staring at this too
> >long..... *:-(

>
> What's the datatype of EmployeeID? What are the RowSource and the Bound Column
> of the combo box Employee? If you put a breakpoint in your code (mouseclick
> the grey bar to the left of the DoCmd.OpenForm line) what is the value of
> strWhere?
>
> My guess is that either EmployeeID is a Text field requiring quotemarks:
>
> strWhere = "[EmployeeID] = '" & Me.Employee & "'"
>
> or the combo box isn't returning the expected value.
>
> --
>
> * * * * * * *John W. Vinson [MVP]
> *Microsoft's replacements for these newsgroups:
> *http://social.msdn.microsoft.com/For...-US/accessdev/
> *http://social.answers.microsoft.com/.../en-US/addbuz/
> *and see alsohttp://www.utteraccess.com


The EmployeeID is a number data type. The combo box has a row source
pointing to the employee table.
There are two columns but the bound column is the primary key which is
autonumber.

I will have to check the breakpoint in the morning. Thanks for your
prompt reply.
 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      11th Nov 2011
On Thu, 10 Nov 2011 16:00:38 -0800 (PST), Opal <(E-Mail Removed)> wrote:

>The EmployeeID is a number data type. The combo box has a row source
>pointing to the employee table.
>There are two columns but the bound column is the primary key which is
>autonumber.


Well, that should be ok then... the other question is, what's the Recordsource
of the report you're opening? It does include the EmployeeID I presume? If you
open the query as a datasheet, does it contain the selected ID (or are there
other criteria or filters on the form that might be excluding it)?

And... following Sherlock Holmes's advice to never ignore the obvious solution
- is the Form's DataEntry property perhaps set to Yes? If so you'll only see
the blank new record, not any existing ones.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
Opal
Guest
Posts: n/a
 
      11th Nov 2011
On Nov 10, 7:44*pm, John W. Vinson
<jvinson@STOP_SPAM.WysardOfInfo.com> wrote:
> On Thu, 10 Nov 2011 16:00:38 -0800 (PST), Opal <tmwel...@hotmail.com> wrote:
> >The EmployeeID is a number data type. *The combo box has a row source
> >pointing to the employee table.
> >There are two columns but the bound column is the primary key which is
> >autonumber.

>
> Well, that should be ok then... the other question is, what's the Recordsource
> of the report you're opening? It does include the EmployeeID I presume? If you
> open the query as a datasheet, does it contain the selected ID (or are there
> other criteria or filters on the form that might be excluding it)?
>
> And... following Sherlock Holmes's advice to never ignore the obvious solution
> - is the Form's DataEntry property perhaps set to Yes? If so you'll only see
> the blank new record, not any existing ones.
> --
>
> * * * * * * *John W. Vinson [MVP]
> *Microsoft's replacements for these newsgroups:
> *http://social.msdn.microsoft.com/For...-US/accessdev/
> *http://social.answers.microsoft.com/.../en-US/addbuz/
> *and see alsohttp://www.utteraccess.com


Thanks! John.... your questions helped me troubleshoot this better
and
I found the problem. I was a little overzealous with some coding and
it was confusing either the on open or on load events. Either way,
I found my problem and all is good. Its good to just have a sounding
board once in a while when you get stuck and can't see the forest for
the trees :-)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Could somebody please explain to me what the following error in event viewer means? Event ID 7000, The Active Common Service service failed to start due to the following error: Bill.Canfield@gmail.com Windows XP General 5 21st Jan 2007 06:06 AM
Intel following AMD following Alpha Yousuf Khan Processors 0 24th Dec 2005 11:45 PM
RE: The Web server reported the following error when attempting to create or open the Web project located at the following URL: <URL> =?Utf-8?B?VHJldm9yIEJlbmVkaWN0IFI=?= Microsoft ASP .NET 0 7th Jun 2004 08:36 AM
No sound coming from my external speakers and headphones despite following steps from trouble shoot. =?Utf-8?B?S2VsbHk=?= Windows XP Help 3 6th Apr 2004 02:34 PM
The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/822319ev1'. 'HTTP/1.1 500 Internal Server Error'. chanmm Microsoft ASP .NET 1 5th Mar 2004 09:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:57 PM.