Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2006

Tip: Looking for answers? Try searching our database.

OpenForm with stCriteria

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frank Wagner - 06 Mar 2006 08:40 GMT
I am trying to open a form using a numeric variable as the stCriterea.

My Code is:
   Dim stDocName As String
   Dim stLinkCriteria As String
   Dim intTestID as integer

   intTestID = 50
   stCriteria = "TestID = intTestID"
   stDocName = "FormName"
   DoCmd.OpenForm stDocName, , , stLinkCriteria

It doesn't work.  I'm suspect my problem is the format of the "stCriteria ="
statement, but I'm not sure what it should be.

Any help would be appreciated.

Thanks
Signature

Frank Wagner
fwagner111@aol.com

Stefan Hoffmann - 06 Mar 2006 09:54 GMT
hi Frank,

> I am trying to open a form using a numeric variable as the stCriterea.
>     Dim stDocName As String
>     Dim stLinkCriteria As String
>     Dim intTestID as integer
>     intTestID = 50
>     stCriteria = "TestID = intTestID"
      stCriteria = "TestID = " & intTestID
>     stDocName = "FormName"
>     DoCmd.OpenForm stDocName, , , stLinkCriteria

mfG
--> stefan <--
Stefan Hoffmann - 06 Mar 2006 10:04 GMT
hi,

>> I am trying to open a form using a numeric variable as the stCriterea.
>>     Dim stDocName As String
[quoted text clipped - 3 lines]
>>     stCriteria = "TestID = intTestID"
>      stCriteria = "TestID = " & intTestID
       stLinkCriteria = "TestID = " & intTestID
>>     stDocName = "FormName"
>>     DoCmd.OpenForm stDocName, , , stLinkCriteria
If your original codes is the same as in your posting, then use the
Option Explict in your module headers.

mfG
--> stefan <--
Douglas J Steele - 06 Mar 2006 13:05 GMT
Queries don't know anything about variables, so you need to insure that
you've got the value from the variable in your criteria, not the name of the
variable.

Change

stCriteria = "TestID = intTestID"

to

stCriteria = "TestID = " & intTestID

(if TestID were a text field, you'd need to include quotes around that, like
stCriteria = "TestID = '" & intTestID & "'")

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> I am trying to open a form using a numeric variable as the stCriterea.
>
[quoted text clipped - 14 lines]
>
> Thanks
Frank Wagner - 07 Mar 2006 03:20 GMT
Thanks guys.  It makes sense and works like a charm.
Signature

Frank Wagner
fwagner111@aol.com

> I am trying to open a form using a numeric variable as the stCriterea.
>
[quoted text clipped - 14 lines]
>
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.