0

I have a text box on a form called

txtNID. 

I want to use the value entered into this text box as a column in my query such that it would have the same effect as entering

NID: "1"

I tried using

NID: [Forms]![frmAddCorrespondence]![txtNID]

But it doesn't work. The query contains one column called CustID and I want a second column to contain the value of the txtNID textbox.

I also tried setting a function to define a variable for the column but my VB is so bad I just keep going around in circles! Here's what I did:

Public Function FrmNID()
varNID = Me.txtNID.Value
End Function

Then set the query field as =FrmNID() but it didn't work!

Could really do with some pointers! Thanks, Rob

1
  • Is the form open when you run the query? Is the field really named txtNID? Have you declared a parameter for it (it usually works without one, but it works more reliably with it)? Commented Mar 30, 2011 at 21:21

1 Answer 1

2

Your code should. I have just done this on one of my databases and it works find

Forms![frmStaff_admin]![txtCSR_name]

Just remember that your form has to be open!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.