dbTalk Databases Forums  

listbox question

comp.databases.ms-access comp.databases.ms-access


Discuss listbox question in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Tony_E
 
Posts: n/a

Default Re: listbox question - 02-23-2011 , 01:10 PM






On Feb 23, 2:01*pm, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote:
Quote:
On 23/02/2011 17:34:22, imb wrote:







Hi ; thanks for your ideas. I am sure they are correct and I am sure
I am doing something wrong. I tried both methods:

DoCmd.OpenForm "Form2", , , , , , ptid --> this opened up the
parameter input from query2 (from the second listbox)
I am trying to pass the value without the parameter input
opening.

Hi Tony,

There are several ways.

For bound forms Marsh suggestion is probably the best in using
strWhere.

An example of using OpenArgs in an unbound form is, by including this
line in the OnOpen event of Form2:
Me.RecordSource = SELECT * FROM This_table WHERE CustomerId = &
Me.OpenArgs

Imb

Try

Private Sub List0_DblClick(Cancel As Integer)

* * If Not IsLoaded("Form2") Then
* * * * DoCmd.OpenForm "Form2"
* * End If

* * DoCmd.SelectObject acForm, "Form2"
* * If Nz(List0) = 0 Then
* * * * DoCmd.GoToRecord acForm, "Form2", acNewRec
* * Else
* * * * DoCmd.GoToControl "CustomerID"
* * * * DoCmd.FindRecord List0
* * End If

End Sub

This is a useful function to find if a form is already open

Function IsLoaded(ByVal strFormName As String) As Integer
' ' Returns True if the specified form is open in Form view or Datasheet
view.

* * Const conObjStateClosed = 0
* * Const conDesignView = 0

If If SysCmd(acSysCmdGetObjectState, acForm, strFormName)
conObjStateClosed Then If Forms(strFormName).CurrentView <> conDesignView
Then * * * * * * IsLoaded = True
* * * * End If
* * End If

End Function

This can be useful after updating Form2 for with a new record to get the lis
or combo box in form1 to show the new details Private Sub Form_AfterUpdate()

* * If IsLoaded("Form1") Then
* * * * If Nz(Forms!Form1!List0) = 0 Then * * * * *' Empty
* * * * * * Forms!Form1!List0 = 0
* * * * * * Forms!Form1!List0.Requery
* * * * * * Forms!Form1!List0 = CustomerID
* * * * End If
* * End If

End Sub

Phil- Hide quoted text -

- Show quoted text -
Thanks so much for all your help. I will keep working on it and
hopefully it will work.

Reply With Quote
  #12  
Old   
David-W-Fenton
 
Posts: n/a

Default Re: listbox question - 02-23-2011 , 02:29 PM






Tony_E <bluestealth94 (AT) hotmail (DOT) com> wrote in
news:3305f496-3566-4178-9443-dd1a081bb934 (AT) j35g2000prb (DOT) googlegroups.co
m:

Quote:
The user double clicks on the record they want to see details for.
On that event the second form (Form2) opens up and only the
selected record (from Form1) should show up. The Form2 is based
on a query that has a parameter for the id field.
You're making life entirely too difficult for yourself.

Get rid of the parameter in the detail form.

And just pass the WHERE clause in the DoCmd.OpenForm. That's the
built-in way Access was designed to do this. It's the easy way. Just
use it -- I can't see any reason why you should have a parameter
defined in the targetted form's recordsource, nor why you should get
into the complexities of using the form's OpenArgs parameter. Access
was designed from the beginning to make it easy to open a form with
a specific record loaded. Use that design to make your life easier.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

Reply With Quote
  #13  
Old   
Tony_E
 
Posts: n/a

Default Re: listbox question - 02-23-2011 , 03:28 PM



On Feb 23, 3:29*pm, "David-W-Fenton" <NoEm... (AT) SeeSignature (DOT) invalid>
wrote:
Quote:
Tony_E <bluestealt... (AT) hotmail (DOT) com> wrote innews:3305f496-3566-4178-9443-dd1a081bb934 (AT) j35g2000prb (DOT) googlegroups.co
m:

The user double clicks on the record they want to see details for.
*On that event the second form (Form2) opens up and only the
selected record (from Form1) should show up. *The Form2 is based
on a query that has a parameter for the id field.

You're making life entirely too difficult for yourself.

Get rid of the parameter in the detail form.

And just pass the WHERE clause in the DoCmd.OpenForm. That's the
built-in way Access was designed to do this. It's the easy way. Just
use it -- I can't see any reason why you should have a parameter
defined in the targetted form's recordsource, nor why you should get
into the complexities of using the form's OpenArgs parameter. Access
was designed from the beginning to make it easy to open a form with
a specific record loaded. Use that design to make your life easier.

--
David W. Fenton * * * * * * * * *http://www.dfenton.com/
contact via website only * *http://www.dfenton.com/DFA/
Thanks David, I appreciate that.

Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.