GettingStarted
GettingStarted

Reputation: 7605

What does this mean in Access?

Forms![HiddenUserCheck]![txtStatus]

It appears that there is a form called HiddenUserCheck and there is a textfield called txtStatus

But what do the ! mean between the words?

The actual code is

If Forms![HiddenUserCheck]![txtStatus] = "Sign In" Then

When I debug it and mouse over the words, it says Null

Upvotes: 1

Views: 1800

Answers (3)

Johnny Bones
Johnny Bones

Reputation: 8402

One of the hardest things "n00bs" have with Access is trying to determine when to use the bang (!) and when to use the dot (.). Take a look at this blog for some tips. One solid guide is this: If the object exists, use a dot. If the object is user-created, use the bang.

So:

Forms![HiddenUserCheck]![txtStatus]

and:

Forms![HiddenUserCheck]![txtStatus].Text

Note: "Text" exists in Access, and so is preceded by a dot. HiddenUserCheck and txtStatus are user-created words, and so are preceded by a bang.

Upvotes: 2

HansUp
HansUp

Reputation: 97101

! is used to reference one member of a collection ... CollectionName!MemberName

Forms is the name of a collection whose members are Form objects, and includes those forms which are currently open in your Access session.

A Form has a collection of Control objects. So appending !ControlName to the form reference gets you a reference to that control.

So Forms![HiddenUserCheck]![txtStatus] refers to a control named txtStatus in a form named HiddenUserCheck which is open in your Access session.

What you get from that reference is the control's default property, Value ... the value contained in that control.

Upvotes: 2

Acantud
Acantud

Reputation: 508

Forms refers to the collection of all forms, HiddenUserCheck is a form in the group of all forms, and txtStatus is a field on HiddenUserCheck form. The !s are a way of seperating that info out. Forms!HiddenUserCheck!txtStatus equates to "The txtStatus field in the form HiddenUserCheck in the collection of all forms. !

Upvotes: 0

Related Questions