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 March 22nd, 2006, 08:55 PM
Registered User
 
Join Date: Mar 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default AccessVB: DoCmd.Openform

Hello,
I'm having an issue trying to load a form based on 2 text boxes. Here is the code I'm currently using:

    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim stLinkCriteria1 As String

    stDocName = "frm_Prod_Entry"

    stLinkCriteria = "[Date]=" & "#" & Me![Combo11] & "#"
    stLinkCriteria1 = "[Shift]=" & "'" & Me![Combo16] & "'"

    DoCmd.OpenForm stDocName, , , stLinkCriteria And stLinkCriteria1

I receive a type mismatch error I believe because the And is putting the two together. Is there a way to use two variables to load a specific form record?

Thanks,
Andy

 
Old March 23rd, 2006, 03:11 AM
Authorized User
 
Join Date: Mar 2006
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Dim stDocName As String
    Dim stLinkCriteria As String
    Dim stLinkCriteria1 As String

    stDocName = "frm_Prod_Entry"

    stLinkCriteria = "[Date]=" & "#" & Me![Combo11] & "#"
    stLinkCriteria1 = "[Shift]=" & "'" & Me![Combo16] & "'"

    DoCmd.OpenForm stDocName, , , stLinkCriteria & " And " & stLinkCriteria1

Peko

 
Old December 10th, 2006, 06:08 PM
Registered User
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Long time Access user (self-taught)

I just wanted to say thanks:

---to Andy for posting the problem which was similar to mine
---to Peko for the posting the solution

I spent 4 solid hours rearranging punctuation, saving, trying, etc.
None of my books even list the term "stLinkCriteria" in their indexes!

I was trying to use 2 criteria w/o the second stLinkCriteria1 and w/o the " " around the And operator. I swear that I have not had to use this in past similar circumstances.

Much appreciated.

Greg M.





Similar Threads
Thread Thread Starter Forum Replies Last Post
DoCmd Openform arguments BBWEST Access 1 August 21st, 2008 10:23 AM
DoCmd.OpenForm BBWEST Access 1 August 21st, 2008 10:02 AM
DoCmd.OpenForm does not work jansb000 Access VBA 1 March 25th, 2008 06:45 AM
Docmd.Openform problem mkobulni Access VBA 7 August 29th, 2007 09:05 AM
DoCmd.OpenForm turp Access VBA 2 December 15th, 2006 08:33 AM





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