Jack -
Of course everyone knows!
Just kidding. The code you used was:
DoCmd.OpenForm "frmTenantInput", acNormal, , [AircraftID] = Forms![frmTenantInfo]![AircraftID], , acDialog
If you look at what the WhereCondition really is you might understand why it ran without errors but failed to do what you wanted.
This line:
[AircraftID] = Forms![frmTenantInfo]![AircraftID]
will always return True since it's just two ways of saying the same thing, AricraftID. So your WhereCondition is the same thing as saying -1 = -1. All that's going to do is get all records.
If you put your cursor on OpenForm and press F1 the help file will open to that entry. Note the WhereCondition is a string. All strings must be in quotes so the compiler knows they are literals.
Going further, you have to use Forms![frmTenantInfo]![AircraftID] as a variable. You can't use it in VBA and have it evaluated properly. That's why its value is concatenated to the string and not used directly in the string.
Regards,
Bill Mosca, Founder - MS_Access_Professionals
http://www.thatlldoit.com
Microsoft Office Access MVP
https://mvp.support.microsoft.com/profile/Bill.Mosca
--- In MS_Access_Professionals@yahoogroups.com, "robsonjack" <robsonjack@...> wrote:
>
> Duane:
>
> Thanks. That works very nicely. But why didn't my approach work? I had previously tried a string similar to yours in the DoCmd OpenForm line. The examples in Access (and in the Microsoft developer forum) never mention having to declare a string outside that cmd. Was that one of those everyone knows that things?
> Jack
>
> --- In MS_Access_Professionals@yahoogroups.com, "Duane" <duanehookom@> wrote:
> >
> > Change your code to:
> > Dim strWhere as String
> > strWhere = "[AircraftID] = '" & Me.AircraftID & "'"
> > DoCmd.OpenForm "frmTenantInput", acNormal, , strWhere, , acDialog
> >
> > Duane Hookom
> > MS Access MVP
> >
> > --- In MS_Access_Professionals@yahoogroups.com, "robsonjack" <robsonjack@> wrote:
> > >
> > > I'm sure I'm missing something simple but any help would be greatly appreciated. I cannot get the "where" portion of OpenForm ... to work. I've uploaded a file called Troubleshooting11 to the downloads section. You have no idea how long I've messed with this.
> > >
> > > Thanks for any help.
> > >
> > > Jack
> > >
> >
>
Rabu, 21 Maret 2012
[MS_AccessPros] Re: Cannot Solve a Simple OpenForm Problem
__._,_.___
.
__,_._,___
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar