Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 21st, 2007, 10:31 AM
Friend of Wrox
 
Join Date: Apr 2007
Posts: 110
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via MSN to ayazhoda
Default Form opening with filters

Hi All

I am trying to open Form B from click event of Allocate button which is on Form A.
but somehow its not opening

Code in Form A
Private Sub Allocate_Click()
Dim q As New ADODB.Command, criteria As String, r As New ADODB.Recordset

If sf(23) Then Exit Sub
DoCmd.Hourglass True
Application.RunCommand acCmdSaveRecord
criteria = "[MID]=" & Me!MID
DoCmd.OpenForm "Stock Allocation Grid", , , criteria
DoCmd.Hourglass False
End Sub


Form Properties of B
Record Source:[Table_Name]
Record Source Qualifier:[dbo]
Filter:[Empty]
Order By:[Item]


Private Sub Form_Open(Cancel As Integer)
 Me.OrderBy = "Item"
 Me.OrderByOn = True
End Sub

any suggestion or advice

 
Old August 21st, 2007, 10:46 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I am not sure what this means:

If sf(23) Then Exit Sub


Otherwise, I would do this:

Private Sub Allocate_Click()
Dim sDoc As String
Dim sLink As String
Dim iMid As Integer

iMid = Me.MID

sLink = "[MID] = " & iMid
sDoc = "Stock Allocation Grid"

DoCmd.OpenForm sDoc, , , sLink

Works every time.




mmcdonal
 
Old August 22nd, 2007, 03:58 AM
Friend of Wrox
 
Join Date: Apr 2007
Posts: 110
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via MSN to ayazhoda
Default

Hi, Good Morning

I did add this line of code in Form B in form open event

Filter="MID=Forms!Orders.MID"

and I've tried to Print values in immediate window using


Print MID
 38059 [wrong value]
and FormB get all value associated with that record number [38059] from table
I am not sure but i have feeling some thing wrong in form properties which is
DATA TAB
Record Source-->Table Name
Record Source Qualifier-->dbo
Filter-->[MID]=Forms!Orders.MID
Order By-->Item
Allow Filter-->Yes
Allow Edits-->Yes
Server Filter-->[MID]=38059 ' I am not sure why we have this here
Server Filter By Form-->No



Print Me.Filter
[Empty]

Print Forms!FormA.MID
 40849 [Correct value]

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening 1 form from another jainin_shah9 C# 2005 5 February 18th, 2008 07:31 AM
Opening a Form arholly Access 1 January 17th, 2007 11:59 AM
Closing a form after opening another form rosebushr Access 2 January 7th, 2006 04:34 AM
Opening 1 form from 2 forms rocknrisk Access 5 July 29th, 2005 06:05 PM
form opening with where clause ginoitalo Access 4 December 22nd, 2004 09:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.