Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / March 2007

Tip: Looking for answers? Try searching our database.

Listbox Selection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Asif - 30 Mar 2007 10:26 GMT
I have a form with a List Box(lst_entry), upon clicking on an entry a
new form (frm_edit) should load up showing the details of the entry
selected in listbox.

In the "On Dbl Click" event I've used the following code;

Private Sub Lst_entry_DblClick(cancel As Integer)
DoCmd.OpenForm "frm_edit", , , "BINPROCESSID = " & lst_entry.Column(0)
&
" and BINPROCESSDate = " & lst_entry.Column(1)
End Sub

However I'm getting the following error message every time I dbl
click
on an item in the list;

Run-time error '3075': Syntax error (missing operator) in query
expression 'BINPROCESSID = 43 and BINPROCESSDate=16/03/07 15:11:06',

Any ideas what I'm doing wrong??

Thanks
Brendan Reynolds - 30 Mar 2007 10:30 GMT
Answered in another thread in this newsgroup.

Signature

Brendan Reynolds
Access MVP

>I have a form with a List Box(lst_entry), upon clicking on an entry a
> new form (frm_edit) should load up showing the details of the entry
[quoted text clipped - 18 lines]
>
> Thanks
Asif - 30 Mar 2007 10:38 GMT
Thanks Brendan, the form opens but it doesn't pick up the data I've
selected from the listbox!!! Is there something wrong with my coding?
Brendan Reynolds - 30 Mar 2007 10:43 GMT
Probably the date format. That's why I recommended looking at Allen's
article. It's all there in the article, explained much better than I could
explain it here and now.

Signature

Brendan Reynolds
Access MVP

> Thanks Brendan, the form opens but it doesn't pick up the data I've
> selected from the listbox!!! Is there something wrong with my coding?
Asif - 30 Mar 2007 17:11 GMT
On 30 Mar, 10:43, "Brendan Reynolds"
<brenr...@discussions.microsoft.com> wrote:
> Probably the date format. That's why I recommended looking at Allen's
> article. It's all there in the article, explained much better than I could
[quoted text clipped - 8 lines]
>
> - Show quoted text -

I've read Allen's article but i don't think thats whats causing the
problem unless i'm mistaken

need more help plz!!
Douglas J. Steele - 30 Mar 2007 17:29 GMT
> On 30 Mar, 10:43, "Brendan Reynolds"
> <brenr...@discussions.microsoft.com> wrote:
[quoted text clipped - 7 lines]
>
> need more help plz!!

You're not enclosing your dates in # characters.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

RoyVidar - 30 Mar 2007 18:21 GMT
"Asif" <asifhashmani@hotmail.com> wrote in message
<1175271081.001829.73300@p77g2000hsh.googlegroups.com>:
> On 30 Mar, 10:43, "Brendan Reynolds"
> <brenr...@discussions.microsoft.com> wrote:
[quoted text clipped - 16 lines]
>
> need more help plz!!

I think there might be several challenges with your initial approach.

One, is that the row source of the listbox probably contains a valid
date/time, which when presented in, and collected from a listbox,
becomes a text. The coersion/conversion, implicit or explicit, between
dates and text, is among the issues creating frustrations when working
with databases. I would recommend trying to avoid such, and only
convert to text when you are sure you wont need to convert it back to a
date again.

The next, as described in Allen Brownes article, that when you "feed" a
date into a string, which is passed to the Jet engine for
interpretation, it needs to be in a format Jet understands. Jet will
understand the format described in the mentioned article, or for
instance the ISO 8601 format "yyyy-mm-dd hh:nn:ss", and it needs the
date enclosed in octothorpes (#) - that is, if the field is defined as
Date/Time.

So, if you are positive the text in the listbox will be consistant, you
could try something like this:

...and BINPROCESSDate = #" & _
        Mid$(Trim$(lst_entry.Column(1)), 4, 2) & _
        "/" & Mid$(Trim$(lst_entry.Column(1)), 1, 2) & _
        "/" & Mid$(Trim$(lst_entry.Column(1)), 7) & "#"

Which - if I've typed reasonable correctly, should become something
like

and BINPROCESSDate=#03/16/07 15:11:06#

i e mm/dd/yy hh:nn:ss

You may test by assigning to a string, then typing to the debug window

dim s as string

s = "BINPROCESSID = " & lst_entry.Column(0) & _
        " and BINPROCESSDate = #" & _
        Mid$(Trim$(lst_entry.Column(1)), 4, 2) & _
        "/" & Mid$(Trim$(lst_entry.Column(1)), 1, 2) & _
        "/" & Mid$(Trim$(lst_entry.Column(1)), 7) & "#"
debug.print s

Then hit ctrl+g to pick up the criterion from the immediate pane.

You should be able to copy/paste from there, into the SQL view of a
query based on this table as the WHERE clause (add the keyword WHERE
too), and test whether it is correct or not.

Signature

Roy-Vidar

Brendan Reynolds - 30 Mar 2007 21:24 GMT
Hopefully the advice you've received from others has been enough to resolve
the problem. But if you're still stuck, try posting the expression as it now
stands. We haven't seen any of the changes you've made since you posted the
original expression that didn't include the delimiters, so we're trying to
debug an expression that we haven't seen. If you post the expression as it
now stands, someone will probably be able to see what the problem is.

Signature

Brendan Reynolds
Access MVP

> On 30 Mar, 10:43, "Brendan Reynolds"
> <brenr...@discussions.microsoft.com> wrote:
[quoted text clipped - 17 lines]
>
> need more help plz!!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.