A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Event - OpenForm



 
 
Thread Tools Display Modes
  #1  
Old August 24th, 2005, 04:49 PM
Linda
external usenet poster
 
Posts: n/a
Default Event - OpenForm

I am trying to open a form based on an entry in a combo box. My select
statement for the comob box is:

SELECT VENDOR.vCODE, VENDOR.VENDOR FROM VENDOR ORDER BY VENDOR.VENDOR,
VENDOR.vCODE;

The event procedure is:

Private Sub cmdOpenForm_Click()
On Error GoTo Err_cmdOpenForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Edit Vendor"

stLinkCriteria = "[VCODE]=" & Me![cboentercode]
DoCmd.OpenForm stDocName, , stLinkCriteria, acFormEdit


Exit_cmdOpenForm_Click:
Exit Sub

Err_cmdOpenForm_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdOpenForm_Click

End Sub

When you click the command button, all the records show instead the chosen
record, based on the vendor code or vcode. I can't figure out where the
problem is. Can anyone help?
--
Linda
  #2  
Old August 24th, 2005, 05:41 PM
Klatuu
external usenet poster
 
Posts: n/a
Default

You just have strLinkCriteria in the wrong place. What you have is:
DoCmd.OpenForm stDocName, , stLinkCriteria, acFormEdit

It should be:
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit

The third argument is FilterName. It is the valid name for query in the
current database. What you want is WhereCondition which is what you have in
your code. One other note, however, your WhereCondition assumes [VCODE] is a
number. If it is a string, then it should be:
stLinkCriteria = "[VCODE]= '" & Me![cboentercode] & "'"

"Linda" wrote:

I am trying to open a form based on an entry in a combo box. My select
statement for the comob box is:

SELECT VENDOR.vCODE, VENDOR.VENDOR FROM VENDOR ORDER BY VENDOR.VENDOR,
VENDOR.vCODE;

The event procedure is:

Private Sub cmdOpenForm_Click()
On Error GoTo Err_cmdOpenForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Edit Vendor"

stLinkCriteria = "[VCODE]=" & Me![cboentercode]
DoCmd.OpenForm stDocName, , stLinkCriteria, acFormEdit


Exit_cmdOpenForm_Click:
Exit Sub

Err_cmdOpenForm_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdOpenForm_Click

End Sub

When you click the command button, all the records show instead the chosen
record, based on the vendor code or vcode. I can't figure out where the
problem is. Can anyone help?
--
Linda

 




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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Canceling the OnKeyDown event John S. Ford, MD General Discussion 8 November 30th, 2004 05:39 AM
Value is Negative Code Problem! Dave Elliott Using Forms 15 November 10th, 2004 01:29 PM
Combo Box -- Select Text and On Change Sheldon Penner Using Forms 4 November 8th, 2004 04:49 AM
raise event of access control vdavid General Discussion 3 June 15th, 2004 03:35 PM
MsiInstaller Events on a Win2000 Terminal Server jwgoerlich Setup, Installing & Configuration 0 May 26th, 2004 06:30 PM


All times are GMT +1. The time now is 12:27 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.