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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Locks Records in a textbox control Conditionally!

Status
Not open for further replies.

Jawad77

Programmer
Dec 23, 2004
41
US
I have a texbox control "RP_tbx" on my form that shows all records at the same time (continuous form view). I like to lock only records(values) in my "RP_tbx" textbox field that have a fiscal week less than the current fiscal week. Here is an example:


FiscalWeek txtbox Feild1 txtbox Field2 txtbox
47 100 200
48 300 400
49 500 600
50 700 800
51 900 1000



Let's say the current fiscal week is 50. So I like to lock the records that have a fiscal week < 50. In other words, I like to lock values (200, 400 and 600) in my Field2 txtbox. But I don't want to lock values (800 and 1000) in my field2 txtbox because they have a fiscal week >= 50.

I can check in VBA form module what my current fiscal week is but I don't have any clue how to conditionally lock records in my field2 text box.

Any ideas/help will be highly appreciated. Thanks in advance.

Jay



 
Something like this:

[tt]me!field2.locked = (me!FiscalWeek .value<50)[/tt]

(or replace the number 50 with the variable holding the current fiscal week)

Use it in for instance in the on current event of the form. You may perhaps set focus to another control first (me!FiscalWeek.setfocus).

Roy-Vidar
 
You'll want to put your code in the Form_Current() event of the form:
Code:
Private Sub Form_Current()
  Me!Field2.locked = (Me!FiscalWeek.Value < GetCurrentWeek())
End Sub

Function GetCurrentWeek() As Integer
  [green]'whatever code you use to find fiscal week[/green]
  GetCurrentWeek = DatePart("ww", Date, vbSunday, vbFirstJan1)
End Function


VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top