1

I'm a complete beginner, just trying out/looking into Databases as more of a hobby, and think Microsoft Access would be an easy way to start with the whole front-end forms and back-end combination.

I just have a form with a combo box [UserNameEntry] that you can select a value from a table 'Users' in a 'Alias' field and then just press a button [Command27], and another text box will have its text replaced by that string. This is more of a test/precursor before me wanting to set it to get the record matching the 'Alias' value selected in the combo box, then checking if another field in that same record matches a particular value.

I don't mind if any help is in the expression, macro or VBA builder, all is good to learn.

I tried the following expression in the On Click event of the button [Command27] (and many other alternatives) but haven't had much luck:

=[Command27].[Caption]="[Users]![Alias]=" & "[UserNameEntry]"

Any help would be appreciated!

HackSlash
  • 171
  • 6
SamuraiMelon
  • 123
  • 3

1 Answers1

1

There are multiple problems with this approach.

  1. A caption is a constant, it can't be assigned an expression.

  2. Make a textbox that looks like the object you want.

  3. You don't need an OnClick event. You can simply set the control source of the text box to an expression that points to the combobox value.

    =DLookUp("[Alias]","Users","[Users].[UserName] = " & [UserNameEntry])

Finally, if you want to use a click event you can. You would need to make a VBA procedure that contains the action. Then call that from the OnClick event.

Public Sub Command27_Click()
    Command27.Caption = "[Users]![Alias]=" & [UserNameEntry]
End Sub
Hannah Vernon
  • 70,928
  • 22
  • 177
  • 323
HackSlash
  • 171
  • 6