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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |