VB code for checking if a field is not null (for locking a row) is needed

hi,

I need to automatically lock a field after it's been written into and
has lost focus.  Right now I'm using a checkbox, but I want to lock
automatically once the field is dirtied (written into) and it loses
focus.

Actually I need to lock a row, but a field is a good start--I can
replicate the code for each field in a row I guess.

Any ideas?

RL

What I'm using now; it works, but you manually have to check a
checkbox, and I want to automate this:

    If boolcheckbox = True Then

        field001.Locked = True

    Else
        field001.Locked = False

    End If
0
raylopez99
12/24/2007 4:06:47 PM
access.formscoding 7493 articles. 0 followers. Follow

3 Replies
1640 Views

Similar Articles

[PageSpeed] 31

On Dec 24, 8:06 am, raylopez99 <raylope...@yahoo.com> wrote:
> hi,
>
> I need to automatically lock a field after it's been written into and
> has lost focus.  Right now I'm using a checkbox, but I want to lock
> automatically once the field is dirtied (written into) and it loses
> focus.
>
> Actually I need to lock a row, but a field is a good start--I can
> replicate the code for each field in a row I guess.
>
> Any ideas?
>
> RL
>
> What I'm using now; it works, but you manually have to check a
> checkbox, and I want to automate this:
>
>     If boolcheckbox = True Then
>
>         field001.Locked = True
>
>     Else
>         field001.Locked = False
>
>     End If

You could put your code into the Form_Current event, so that:

Me.SomeField.Locked = Me.chkCheckbox.True

..... this would lock a field if your checkbox is true. If you want to
make it generic, create a module with...

Public Function LockMyField (chk as Checkbox) as Boolean
   LockMyField = chk.Value
End Function

.... and call the function from the Form_Current event. If you provide
a little more detail, I can give you more of my two cents.

-- James
0
Minton
12/24/2007 4:29:09 PM
You will need code in two places.  One in the Lost Focus event of the text 
box. (it is not a field, fields belong to tables and queries.  On forms and 
reports, they are controls).

    If Not IsNull(Me.MyTextBox) Then
        Me.MyTextBox.Locied = True
    End If

And also in the Form current event to set it correctly for the record:


    If Me.NewRecord Then
        Me.MyTextBox.Locked = False
    ElseIf IsNull(Me.MyTextBox) Then
        Me.MyTextBox.Locked = False
    Else
        Me.MyTextBox.Locked = True
    End If
        

-- 
Dave Hargis, Microsoft Access MVP


"raylopez99" wrote:

> hi,
> 
> I need to automatically lock a field after it's been written into and
> has lost focus.  Right now I'm using a checkbox, but I want to lock
> automatically once the field is dirtied (written into) and it loses
> focus.
> 
> Actually I need to lock a row, but a field is a good start--I can
> replicate the code for each field in a row I guess.
> 
> Any ideas?
> 
> RL
> 
> What I'm using now; it works, but you manually have to check a
> checkbox, and I want to automate this:
> 
>     If boolcheckbox = True Then
> 
>         field001.Locked = True
> 
>     Else
>         field001.Locked = False
> 
>     End If
> 
0
Utf
12/24/2007 8:24:00 PM
On Dec 24, 3:24=A0pm, Klatuu <Kla...@discussions.microsoft.com> wrote:
> You will need code in two places. =A0One in the Lost Focus event of the te=
xt
> box. (it is not a field, fields belong to tables and queries. =A0On forms =
and
> reports, they are controls).

Yes, thanks, this worked Klatuu.  Milton M's solution wasn't as
intuitive to me so I didn't try it (though I have figured out that VB
likes to cast stuff using the "As" keyword and that "me" is what C#/C+
+ calls the 'this' pointer).

Access forms using VB is great for rapidcoding...

RL

0
raylopez99
12/25/2007 10:28:44 PM
Reply:

Similar Artilces:

Wachovia requires 3 login fields
Help! My bank, Wachovia requires 3 login fields: Customer Access Code, PIN and Codeword. MS Money is asking for only 2 items: ID and password in the "Step 5 Online Setup". What is the solution. Thanks. Contact Wachovia and ask for an ID and password to use with MS Money. Doug "Chris" <cptxaggie@yahoo.com> wrote in message news:26d0001c38eb5$9ace1e10$a601280a@phx.gbl... > Help! My bank, Wachovia requires 3 login fields: Customer > Access Code, PIN and Codeword. MS Money is asking for only > 2 items: ID and password in the "Step 5 Online Setup"....

Exceeded characters in field
I'm new to CRM so this may seem like a silly question. I'm entering a lot of text in the Notes field of an Account, and receive a message that says I've exceeded the maximum number of characters for the field. Is there a way I can increase the number of characters for the field? Not sure if this is done at a DB/application level (if it is possible). Thanks You cannot increase the size of the notes Suggest either (1) create multiple notes, or (2) (better) write up your comments in a file that you attech to a note Peter "Aaron" <aaron.heller@gmail.com> wrote...

VB distmon?
Hi I have recently installed Office 2003. A couple of wired things happen in Excel: > Everytime I close the program I get a MS VB error that reads "Compile error in hidden module: Distmon" Every time open the program I get the same error, but the macro it is calling is "autoexecnew" > Since my new installation, I type in an simple function like TRIM and it tells me cannot find project library. any ideas? Thnaks! Alan Alan http://support.microsoft.com/default.aspx?scid=kb;EN-US;q307410 OFF: "Compile Error in Hidden Module" Error Message When You Sta...

Ex2k3 version check
How does one check for the latest installed service pack version???? If you go into Exchange System Manager, and click on the Servers container you will get a list of the servers in your Exchange organization is the right-hand pane, there is a column called "Server Version" and you will see the Service Pack level listed there. You can also open the properties for the individual server and see the Service Pack level listed on the General tab. -- Mark Fugatt Exchange MVP http://www.exchangetrainer.com http://www.msexchange.org "Michael Griffith" <mikeg@edgereports...

Mutual fund codes
I have a mutual fund that I cannot get the prices for. The code is CA:AIM3593 and Money does not list that fund. I'm upgrading from Quicken 2002, which could download prices for this fund and I'm deciding between the latest versions of Money and Quicken. There are 7 other funds that I cannot get prices for because Money does not list the fund. The codes are all available at https://www.cannex.com/canada/english/fund/fp030ae.html and all work with Quicken. -- If you can keep your head about you, while all those around you are losing theirs, you just don't understand the...

Summing every 12 rows
I've got 180 rows (these are months). I want to sume every 12 rows and make rows that has this sum to represent a year...how would I do that? Hi Vincent, Do you mean every 12th row =SUMPRODUCT(--(A1:A100)*(MOD(ROW(A1:A100), 12)=0)) or 1-12 for Jan, 13-24 for Feb, then =SUMPRODUCT((A1:A180)*(ROW(A1:A180)>(MONTH(I1)-1)*12)*(ROW(A1:A180)<=(MONTH( I1)*12))) where I1 holds a date for the month to be totalled -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Vincent Lee" <axwack...

Globally change part of a field
I have a text field that holds the file location of a picture. The content looks like this: H:\Access Data\Personnel Pictures\picturefile.bmp The "picturefile.bmp" is different for every record. Everything preceding it is identical in all records. I've moved the folder with all the pictures to a new location and need to update this field to the following: S:\Everyone\Member Database\Personnel Pictures\picturefile.bmp So basically, I need to swap out "H:\Access Data" for "S:\Everyone\Member Database" in every record. How so? Thanks in advance. Jer...

Duplicate detection (looking for code)
I would like to add code to detect for duplicates or records with similar information. Looking to do this check on (firstname and lastname) and on address (street1, street2, city, state, zip) But I want something a little more advanced than just checking for exact matches. Wondering if anyone has some code they would care to share that might make my job of writing it a little easier? Example: Bob Smith and Bobby Smith would be detected as duplicates Rob Jones and Robert Jones would be detected as duplicates 123 main street pittsburgh, pa 15126 123 main st pittsburgh pa 15...

Bar code scanners
Hello All! I have a warehouse facility and several stores and am trying to find a way to use a barcode scanner with internal memory to scan large orders (200 pieces or greater) that i can then hook to my pc with RMS and "dump" the information into either a transfer out or an invoice. has anyone done this? if not does anyone have any recommendations? is there a person i could contact that may be able to write a short program or executable to make this happen? I would appreciate any and all information anyone may be able to provide. Thanks, Jim Hi Jim, I don't kno...

NTBackup Question
Can I install Exchange System manager on a Windows 2000 machine and backup Exchange 5.5 remotely using ntbackup? I know this is possible in Exchange 2000. Well, easy enough to test, but IIRC, yes. In NTBACKUP options, you will see the E200x Org and under a separate tree with the old 5.5 email icon, the 5.5 org. But, its been awhile, so I may just getting senile :) On Wed, 6 Oct 2004 13:49:10 -0700, Teo Gomez <TeoGomez@discussions.microsoft.com> wrote: >Can I install Exchange System manager on a Windows 2000 machine and backup >Exchange 5.5 remotely using ntbackup? I know...

Deleting a Row based on cell value
Friends My work sheet contains 5000 rows I have to delete entire row when ever Column A contain data "NA" How to automate this? Thanks in advance Babu ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ Babu, Use a macro Private Sub DeleteNA() Dim x As Integer For x = 5000 To 1 Step -1 If Sheets("Sheet1").Range("A" & x).Value = "NA" Then Rows(x).EntireRow.Delete End If Next x End Sub HTH Henry "Babu" <Bab...

How do I return which row the active cell is in?
Before I start, thanks to all the people who've already helped me on this board. Solely because of you, I've managed to complete 10% of a simple but large project (2 applications so far). I've hunted the boards now for a couple of hours and haven't found the answer to a very simple issue. What I want to do is this: I have a worksheet with data already on it. I want to cut and paste data from another worksheet. I need to identify the first empty row at the end of the data and return its row number. I tried the following. Sub test() Dim lRowNum As Long Range("A655...

How To Set The Default Fields Displayed
I use lots of folders and sub-folders. I create 2 or 3 or more every week. How do I set the default fields displayed? I have only found that right-clicking on the bar and removing columns I don't want, then right-clicking again and selecting 'Field Chooser" allows me to make this as I want. Can't I just go to a place and say for every new folder, here are the fields I want displayed? See http://www.outlook-tips.net/howto/grouping.htm for the method to use. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exch...

I need a formula #2
hi, please help. A1's value is "red" A2's value is "green" how to achieve this: When I input "1" in A3, A4 appear A1's value, When I input "2" in A3, A4 appear A2's value thanks! Hi =INDIRECT("A" & A3) or =OFFSET(A1,A3-1,0) Arvi Laanemets "ldh" <ldh@ldh.com> wrote in message news:195001c372c0$d7d3dfe0$a401280a@phx.gbl... > > hi, please help. > > A1's value is "red" > A2's value is "green" > > how to achieve this: > > When I input "1"...

Colorising cells from code
I am using the code below which runs whenever a cell is edited -I think. I would like to change this code so that it can be 'run' against a range of cells rather than as Worksheet_Change code. What do I need to do to do that ? Thanks Sub Worksheet_Change(ByVal Target As Range) Dim icolor As Integer If Range("A1").Value = "" Then If Not Intersect(Target, Range("B4:J34, B35:B39")) Is Nothing Then Select Case Target Case Sheet3.Range("A4") icolor = 34 Case Sheet3.Range("A5") icolo...

Genuine Validation Check
I legitimately own a number of copies of Windows XP and I wish to install Media Player 11 on those PCs. The problem is that the PCs are part of a secure system which has no internet connection and can never be connected to the internet. Is there an alternative way to validate my Media Player 11 installations? e.g. Telephone? Or email? On Thu, 28 Jan 2010 05:36:02 -0800, Simon <Simon@discussions.microsoft.com> wrote: > >I legitimately own a number of copies of Windows XP and I wish to install >Media Player 11 on those PCs. The problem is that the PCs are part of ...

EAN 14, Dun 14
Hi, I have a printer TLP 2844 (Zebra) and I need to print bar codes using EAN 14 or Dun 14. Anyone have any idea how I can do that? I want just a simple sample in how do that. I posted this question here in excel forum because there isn't any group related as bar codes and because I want to work with that using just Excel. Thanks in advance, Magno magno_jr@terra.com.br You will need to buy a software designed for barcode like Lableview. EAN14 is not a common barcode so make sure it will do that. If you call Zebra, I think they sell something, if not they can recommand on...

Code does not work on merged cells
The following code works fine on single cells but I also have Dat Validation which for cosmetic purposes merges to the next cell e.g Cell B3 merges into cell C3 - why, if I use either B3 or B3:C3 in th code below does it not work? i.e. I should get an error message if try to delete data from one of the cells. Thanks _Code_ Application.EnableEvents = False If (Len(Range("b10")) = 0) Or (Len(Range("c10")) = 0) O (Len(Range("f10")) = 0) Then With Target If .Value = "" Then Application.EnableEvents = False .Value = "Invalid" MsgBox "You ...

Excel VB
I have two cells in a workbook that are dates. The cell Start_Date has a valid date in it. The second cell Test_Date is either blank or has a valid date in it. The IsDate test on both cells works fine, however, on a blank cell the Month function extracts "12". Anyone know why? I had to put the month function within a test for IsDate to make it work. Seems like Month function on a blank cell should return something other than a 12. Dave Test code: If IsDate(Range("Start_Date")) Then 'Cell has 11/01/09 in it. MsgBox ("start date a d...

Cannot Add any window to VB
Hello: I'm using a VM with GP 10.0 SP3 installed. In order to have the same as our production databases i copy the GP folder, entirely, which i think it was a mistake now I'm getting a "This cannot be added to Visual Basic", whenever i try to add a window, any window, to VB. Also it goes without saying that there's a lot of load errors starting GP. For the record the copy/paste thing worked, sort of, and before you start thinking that i was insane to have done this, there's a reason behind it, There's been a lot of tweaks to our production server, by our p...

i want to insert a check mark box in publisher
I WOULD LIKE TO INSERT A CHECK MARK BOX ON MY DOCUMENT IN PUBLISHER, HOW DO I DO THIS? THANKS ROSY rosygucci wrote: > I WOULD LIKE TO INSERT A CHECK MARK BOX ON MY DOCUMENT IN PUBLISHER, HOW DO I > DO THIS? THANKS ROSY a) Please do not post in ALL CAPS. It is the internet equivalent of hollering at the top of your voice, and is more difficult to understand than sentence case and is rude. b) Use the Wingdings font, and type a 'q'. -- Ed Bennett - MVP Microsoft Publisher http://ed.mvps.org ...

vb from VC++
Hi, is it possible, and if so, to call a Vb macro from VC++. Or manipulate spreadsheets (ie draw graphs from the data within the workbooks) usinbg MFC functions cheers Anthony Presumably you are referring to MS Excel spreadsheets and workbooks. The easiest method would be to import the appropriate type library (.tlb) provided with Excel, having the class wizard generate the classes, which you then use to access the Excel Automation model (that is the same model that Excel VBA uses). Some investigation may be needed to determine which tlb to use, and to make sure you have a basic understand...

Auto assigning department Codes to a Project
We have many projects set up - within each project we assign multiple resources. The resources are often from different departments. Today, we set up a project for each department as we cannot seem to make PA "dynamically" assign our department value based upon the person assigned to the project. Is it possible to have a project dynamicaly assign a department code (a GL segment) based upon the person assigned to the project? -- Dave Not without customization using VBA or Dexterity. -- Charles Allen, MVP "David Schmidtknecht" wrote: > We have many project...

VB in Excel
In Excel I go into Visual Basic Editor, then Visual Basic Help, but when I type 'Passwords' for example it will bring up a list of related items, but some of them you can't select. Does this mean the installation CD is corrupt and hasn't installed all the components? I have reinstalled and repaired the installtion but to no avail. Any ideas anyone? Help! Thanks ...

Cntrl find
I have a large excel worksheet - zip codes, cities, states, area codes ... I need to be able to sort as well as find. Problem comes in with states that have zips starting with zero. I can get them to appear correctly as custom or special, but not able to do cntrl-find and bring up ... I can't believe I can't figure this out ... Format the Zip code column as TEXT and enter the leading zero normally as any other character.........then FIND will "find" it........... Vaya con Dios, Chuck, CABGx3 "jjjJackieCalifornia" <jjjJackieCalifornia@discussions.microsoft...