Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Can I Requery While Staying on The Same Record? 1

Status
Not open for further replies.

MattMeat

Programmer
Nov 6, 2001
38
US
Hello Everyone!

I have put a cmd.requery on a save button in my Service Order Entry Form. When, I requery, I am taken back to the first record. All I wanted to know was how to requery in this form and stay on the same record.

Thanks,
Matt
 
Matt,

You can Refresh and stay on the same record. If you requery, I've found the same thing as you.

However, I've also found that I usually don't need to requery the entire form. Each control can be requeried.

Example: You have TextBox1 that strings together the various parts of an address. When you make changes to the address fields, you can use the AfterUpdate event of those fields to run
Code:
 TextBox1.Requery

Your user changes the street name and when they leave the StreetName field, the TextBox1 is recalculated.



HTH John

Use what you have,
Learn what you can,
Create what you need.
 
Thanks Boxhead,

I really appreciate your help. If you're still there maybe you can answer another quick question:

Can I disable a field in a specific record while keeping the same field enabled in other records?

Thanks again,
Keep up the good work

Matt
 
You could do this by running code in the Form's Current Event. For instance say you had a field txtNInumber which you wanted to 'disable' in some cases. If you created a field in the table called chkFieldLock and set its type to Yes/No. Then in the Form's Current Event use something like:

If chkFieldLock = Yes Then
txtNInumber.Enabled = False
Else
txtNInumber.Enabled = True
End If

You could create one Form with the chkFieldLock visible and another with the chkFieldLock invisible so a user with access to former form could change the Enabled status for the txtxNInumber field and thereby modify the txtNInimber field content, while a user of the latter form could not.

Rod
 
Like Ron said, you can do it. Just run your test with the OnCurrent and any
Code:
  If whatever your test is Then
      YourTextBox.Enabled = False
  Else
      YourTextBox.Enabled = True
  End If

One caution, if the field in question is the first tab stop on the form, you will effectively be trying to disable a control while it has the focus. That's not allowed. Put a line to set the focus somewhere else before disabling.
Code:
      SomeOtherTextBox.SetFocus
      YourtextBox.Enabled = False

John

Use what you have,
Learn what you can,
Create what you need.
 
Actually my contribution, which must seem a weird offering was intended as a reply to another query put up by someone looking for a way to disable fields on a form dependant on what the fields contained. I somehow added it to this thread by mistake and now I can't find the original thread.

One for the X Files??

There's no doubt - Boxhead has it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top