Check Box VBA Code In A Form

Feb 17, 2015

I am trying to create form. I have a check box in my form with the name ChkDone.

I am going to write code for this check box and link it with some fields in my form.

The plan is if the check box is true or yes those fields will be available to insert data and if not they will be disabled.

View Replies


ADVERTISEMENT

Code Before Opening Form To Check User's Right

Oct 23, 2005

Hello Gentlemen,

I am planning to give different rights (AllowEdit, ViewOnly…) to the user on accessing forms and reports in a db on a single pc instead of dealing with server as my client have only one pc.

As a present requirement, db would be in one pc only and would be used by 3-4 users. I need each of users to limit their access to some of the forms and reports in the same pc. To get it, what I did is as follows:

Example:

One of my tables called tblEmployees (Back End Table) linked in FE containing following fields:

1.Unumber- Autonumber
2.UNames - Text
3.Pwd- Password
4.F1- Yes/No
5.F2- Yes/No
6.F3- Yes/No

F1, F2….stands for form1, form2…

There is a login menu form. Something like 2 text boxes on the form and opening at the startup. User selects his name from a combo and types his password. If the user is available in the tblEmployees, Access opens main form and store UNumber and UName with time stamp in a local table called “T_CurrUser. If user not available in tblEmployees, it should close or give some msg.

Now, when the Main form opens (after login with correct user and pwd) and user wants to click different command buttons to open the form, I need to write code to check whether the current user have right to open the selected form (check marked to allow opening this form in the table tblEmployees) BEFORE opening it.

If check mark is set to false on F1 in the table tblEmployees, it means he can’t open form1, and a msg should pop up “Not allowed to view”..Something likes that.

1. I don’t know the code I created with simple if then, where to write ? I mean on which event of form ? On open / On Activate or where. Bcz the code should run before form opens and should check the table whether the user have check mark value true or false.

I tried to write the following code but some time it works some time doesn’t. What is wrong with code lines?

On Click of Command Button that opens Form1

Dim USR = DlookUp(“lngEmpId”,”T_CurrUser”) ‘ Local Table emp.

‘To check if Form1 check mark is set to true
If DlookUp(“F1”,”tblEmployees”,”lngEmpId=USR)=True Then
Docmd.OpenForm “Form1”
Else
End If

When another user logs on the same pc (off course, after login out of first user) the local table T_CurrUser record will be replaced with new user. Note that local table T_CurrUser contains always one record. Hopefully I described correctly.

Any idea will be respected.

With kind regards

Ashfaque

View 3 Replies View Related

Code For Check Box

Feb 22, 2006

friends,

I have a form based on a table (master) with a cbo which returns yes or no according to what users select.

I then have another form which get's its data from a query based on the above table (master). This time, the value I have selected in the previous form using the cbo, should be displayed using a check box.

This is how I would like it to work:

If Me.cbo = yes (meaning that the value selected is yes), then

check box should show be checked.

If Me.cbo indicated NO, then, the check box should not be checked.

Is there a way I can do this via code?

Thanks.

View 3 Replies View Related

DAP-Can Someone Check This HTML Code For Me?

Apr 27, 2005

I'm trying to get a field in my Data Access Page to display the last time a field was updated, I figured I would have to do this in HTML, after a lot of dead ends elsewhere. Here is the code:

<SCRIPT language=vbscript event=BeforeUpdate(dscEventInfo) for=MSODSC>
<!--
Dim DateModified
DateModified = Date 'Current System Date
dscEventInfo.DataPage.Recordset.Fields("DateModified") = Date

-->
</SCRIPT>

Any clues where I would enter this in the HTML source?

View 1 Replies View Related

How Would I Write This Code For Check Boxes

Mar 15, 2006

Here is my problem. I have several fields located on a form. The user has a problem finding the curser on what field its on. I did ok with the text fields, but I need to come up with something for the check boxes. Any Ideas

The code below works good for text fields. But I need to do the same for Check Boxes or the Check Box Label that is associated with the check Box.

Private Sub Ctl4bCode_Enter()
Me.Ctl4bCode.BackColor = RGB(255, 0, 0)

End Sub

Private Sub Ctl4bCode_Exit(Cancel As Integer)
Me.Ctl4bCode.BackColor = RGB(255, 255, 255)

End Sub


thanks

View 1 Replies View Related

Can You Check My Code? Cookie Info Into A Db, Thanks!

Aug 25, 2005

Hey guys nice and easy one im trying to put some info from a cookie into an access database this is the code i have:

Code:<%dim uiduid=Request.Cookies("tmg_login")("MemberID")sql="INSERT INTO genSiteNews (NewsTitle,News,NewsBy)"sql=sql & " VALUES "sql=sql & "('" & Request.Form("NewsTitle") & "',"sql=sql & "'" & Request.Form("News") & "',"sql=sql & "'" & uid & "')"on error resume nextoconn.Execute sql,recaffectedif err<>0 then Response.Write("Error!")else Response.Write("News Entered Ok!")end ifrs.closeoconn.close%>

comes up with error any ideas?

View 1 Replies View Related

Modules & VBA :: Check Datatype And Field Size In Code

Feb 6, 2015

I have created code to import and excel file and create a table from that info. Now I need to confirm that the import has the correct Datatype of Number and Fieldsize of Double for one of the columns.

View 2 Replies View Related

General :: How To Use Code In Button To Check Relationship Integrity

Aug 2, 2012

Suppose I have two tables:

"State"
"City"

Related to the relationship "one-to-many."

They also have enabled:

Enforce referential Integrity and Cascade Update Related Fields

Thus, it is possible to change the name of the state or city, but can not be deleted until the state is associated with some of the city.

I also made a form for the "state" in which is the list that contains a list of all states. The name of the list is "lstState". So that I can delete the "State" I make a button in form and I use the following code:

Code:
Private Sub DeleteState_Click ()
If IsNull (Me.lstState) Then
MsgBox "Select the state you want to delete", vbCritical
else
DoCmd.SetWarnings False

[Code] ....

Everything works fine when the state is not assigned to any one city. But the problem arises when trying to delete a state which is assigned to the city, that is when I select this state and click on the delete button then the state is not deleted - this is ok, but without any message told why the state is not deleted and that's the problem.

My question is how to make the code that the user receives a message that such State can not be deleted because there are cities that are associated with it.

View 1 Replies View Related

Forms :: Make Image Appear In Form When There Is Check In Check Box From Table?

Jun 26, 2014

how can i make a image appear in my form when there is a check in the check box from the table?

View 14 Replies View Related

Modules & VBA :: Code To Check Contents Of A Field In A Table Where Another Field

Sep 11, 2013

I am trying create some code that checks if the contents of the status field in a table is "Authorised" where the ID = something specific for multiple records. If all records witht the specific ID are "Authorised" Then generate a new record in another table. Where to start, perhaps a Dlookup?

View 1 Replies View Related

Forms :: How To Use Data On A Form When Running Code Before Closing The Form

Feb 4, 2014

I have a bound form with a few fields. I would like to run a sub after some of these fields are modified, but not others. I would like it to run only once, after user finishes his work on the form.

When using the Unload event - the form on the form is not there anymore (or did I get something wrong?).

Is there a way to trap Data on form just before the form closes?

View 4 Replies View Related

Form Check Box

Jul 17, 2006

if check box 1 is true then i want to allow the user to select true or false in check box 2. if check box 1 is false the user cant select check box 2

how do i do this:rolleyes:

View 1 Replies View Related

A Bug In My Form, Can Any 1 Help With This Check Box

Jul 26, 2006

Hi, sorry but i have a new issue. Ok, here it goes.

I have a check box on my form that "black lists" that related record. I wish to warn the user that when they click/after update the check box, they will no longer be able to work with this contact unless an administrator unblocks the record.

Here is the VBA for what i have done so far.

Private Sub orgMisc_AfterUpdate()
Dim intAnswer As Integer
intAnswer = MsgBox("Are you sure you wish to Black List this contact?" _
, vbQuestion + vbYesNo, "Time Saver")
If intAnswer = vbYes Then
orgMisc = True
Else
orgMisc = False
End If
End Sub

This works fine except for 1 problem. It prompts me if i change my mind and uncheck the check box. So basically, if (default) is False Then OnClick i want the above VBA to execute. If the check box already isset to TRUE then ignore the above VBA and orgMisc (checkbox) change to FALSE.

If any 1 can offer advice or knows how to solve this issue, that would be great :)

View 1 Replies View Related

Check Box In Form

Dec 26, 2006

I have a table -'client' with 5 fields,
id
name
address
email
mobile no

Through a form,I want to list only those clients who has email id - by using check box

I know its simple but not so simple to a layman like me

Please help

View 3 Replies View Related

Need Code To Open TeacherDetailFrm Form Main Form.

Jun 11, 2007

Hi
I need code to open TeacherDetailFrm form Main form.

I have TeacherStudentSubFr*m on the Mainform, FirstNameTxt on the TeacherStudentSubFr*m, and TeacherDetailFrm.
I need code to open the TeacherDetailFrm By double click on the FirstNameTxt.

I use this code but no data come and query dialog box come.

Private Sub FirstNameTxt_DblCli*ck(Cancel As Integer)
Dim DocSubForm As String
Dim DocText As String
DocSubForm = "TeacherDetailFrm"
'DocText = "[Result]=" & "'" & Me![result] & "'"
DoCmd.OpenForm DocSubForm, , , "[ FirstNameFld ]=forms![TeacherStudentSubFrm]![ FirstNameTxt]"

End Sub


I like to upload the file but no way in this forum

View 2 Replies View Related

Form Check Box Query

Dec 20, 2005

I have a form that has unbound check boxes on it. They are linked to a query. The query has the following script in the criteria section

[Forms]![frmTEST]![Check0]

This is set up so that when I put a check in the checkbox and press the control button it envokes the query. I have 6 boxes on the form with the same script for the exception of the [Check0] number.

Right now the way it is set up I have to check the exact sequence in order to get any data. Is there a way that I can simply check a box and pull up all the records that are checked. (Ex. I check "Box 1" and push the control button. I want it then to show me all the records that have a check in "Box 1" regardless of what the other check boxes are.) So far I have not found a way to do this.

View 2 Replies View Related

Check Box On Form From Query

Jan 24, 2007

Hi
I have a form that displays the results from a query.
I have a check box that users select in order to show they want to print that record
However, it has stopped letting me change the check box, and simply gives me the helpful windows 'bing' when I click on it.
All the controls are set to allow me to write to it.
Has anyone got any ideas of why this might happen?
Cheers
Ben salt
P.S. If I go into the table directly, I can still change the status of the check box

View 2 Replies View Related

VAT Check Box On Order Form

Jan 31, 2005

OK....I have done a search but am still none the wiser regards allowing for VAT (added to an old thread but no luck!).

I am designing a little DB for an accountant at work. He wants to be able to keep tabs on orders he places with various vendors (currently uses excel) but he needs to generate reports etc. I have done this but would like to afford him the ability to add VAT to the order total if required.

So here is what I want to do. I want to add a check box to an Order Form that will add VAT at the current rate. If the VAT rate changes at some point in the future I do not want historic data updated to the new rate.

I want to add it to the Order Form as not all companies being invoiced are VAT registered. This will give the user the option to add VAT or not.

I have had a little play (see attached) but do not know how to get it all working!

Help, advice appreciated (or if anybody has a working example of VAT?).
Cheers,
Phil.

View 5 Replies View Related

Help Reqd For Form Check.

Mar 30, 2005

I am new to access, and no nothing of programming, so please keep any answers simple!!

I have a form which the user then inputs data, I need to check that the data does not exist in a table. I was trying to do this with a validation rule, but can't get anything to work.

Is there a simple of doing this?

Thanks in advance.

View 3 Replies View Related

Check Off Items In Form

Jun 21, 2005

Hello,

I have a form that users type in a part number and a due date. I then run a
report that prints the part number, the components needed and the processes
needed. For example:

------User Form-------

Part 1 6/25/05
Part 2 6/28/05
Part 3 7/1/05


---------Report--------

Part 1 6/25/05

Component 1--------SAW-----WELD------SMOOTH
Component 2--------WELD-----PAINT
-------------------------------------------------------------
Part 2 6/28/05

Component 1--------DRILL-------WELD
Component 2--------SMOOTH-----PAINT
-------------------------------------------------------------
Part 3 7/1/05

Component 1--------DRILL-----PUNCH
Component 2--------CUT-------PAINT
-------------------------------------------------------------


What the users want the ability to check off (and make dissappear) the
processes each day, so they can see what processes are left.

For example, after day 1 with SAW and WELD done:

Part 1 6/25/05

Component 1--------WELD------SMOOTH
Component 2--------PAINT

I'm confused about how to go about this. I don't want the users to have to
manually type in anything. I want the components and processes to show up
when they type in the part number. I want the user to be able to check off
processes as they go, but I want all the processes to show up when they type
a new part in the form. I would appreciate it if someone would point me in
the right direction.

Thank You,

Chad

View 1 Replies View Related

Check Boxes On A Form

Jun 1, 2006

Hi All,

I have a form with a series of check boxes (see image below). The check box is always in the top left had corner and is very small. Does any one know if it is possible to:

a. Have the check box in the centre
b. Enlarge the check box, so the tick itself appears larger

13770

Cheers,

Aaron

View 9 Replies View Related

Check If A Form Is Open.

Sep 7, 2006

Hello everyone,

I have a question:

I have a form in wich I can add and edit employees.
I can open this "employee" form in 2 ways:
1. From another form
2. From the mainmenu

When I close the "employee" form I want to check if the otherform (1.) is open. If it is open I want to requery the other form. If it is closed I don't want to requery the other form.
How can I check if the other form is open?

I hope that you guys can help me and thanks in advance,
Johnny

View 5 Replies View Related

Check For Complete Form

Oct 12, 2004

Im tinkering with a new form for data input..

We use 2 different forms for employees based on status. Pending, and active. Staff members should not be able to be set to active unless all the fields on the Pending form are completed. Is there anyway I can check to make sure the form is completely filled in before allowing a status change to Active?

View 5 Replies View Related

How I Can Check If Form Is Open

Mar 10, 2005

How i can check if form is open ??? sorry for noob question

I want check with VB if form is open or close ???
How i can do it???

example in VC++
if(!dialog.IsOpen())
{
...
}
else
{
...
}

View 5 Replies View Related

Continuous Form And Check Box Help

Apr 14, 2005

I have a continous form that contains text boxes, combo boxes and a check box. Upon clicking the check box, I have added code to disable the text and combo boxes on the corresponding row. However, when I click the check box, all rows are disabled (which is want I don't want).

Is there any way to only have the row, where the check box is checked, to be disable, and none of the other rows (where the check box is not checked)?

View 2 Replies View Related

Check Box Search Form

Oct 9, 2006

Hi all first post but im hoping someone can help. Im tryng to make a form with 3 check boxes on it and a results text box and a command button, that when dependent on if the check box was ticked then after the command buuton is presses this will display the result in the text box?

Im pretty much new to all this any help would be amazing thanks!

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved