473,324 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Default and mandatory field functions

Cyberdyne
627 Expert 512MB
I have two fields

Field1 - has options Yes or No
Field2 - has three options to chose from

First: What do I need to do to make Field1 be No and Field2 not selectable by default?

Second: If Field1 is selected as Yes I want Field2 to become selectable and mandatory.

Let me know, Cyberdyne.
Dec 27 '06 #1
23 3792
willakawill
1,646 1GB
I have two fields

Field1 - has options Yes or No
Field2 - has three options to chose from

First: What do I need to do to make Field1 be No and Field2 not selectable by default?

Second: If Field1 is selected as Yes I want Field2 to become selectable and mandatory.

Let me know, Cyberdyne.
Hi. Are you thinking about a form?
Dec 28 '06 #2
Cyberdyne
627 Expert 512MB
Hi. Are you thinking about a form?


Yes its a form with many fields Field1 and Field2 are the last two fields in the form.
Dec 28 '06 #3
willakawill
1,646 1GB
Yes its a form with many fields Field1 and Field2 are the last two fields in the form.
Then you can make field1 an option group with two radio buttons. When no is selected, as by default, you can make field2 either invisible:
Expand|Select|Wrap|Line Numbers
  1. Field2.Visible = False
or you can disable Field2 so that it is visible and cannot be used
Expand|Select|Wrap|Line Numbers
  1. Field2.Enabled = False
Dec 28 '06 #4
Killer42
8,435 Expert 8TB
Then you can make field1 an option group with two radio buttons. When no is selected, as by default, you can make field2 either invisible ...
or you can disable Field2 so that it is visible and cannot be used
Seems as though a checkbox would be appropriate for Field1, though radio buttons work too.
Dec 28 '06 #5
Cyberdyne
627 Expert 512MB
Ok so how do I do this? All I want is the first field to be visible and defaulted to "No" and the second field to be invisible by default but if the first field is "Yes" I want it to appear and become mandatory.

I created the fields so lets assume I have Field1 and Field2 what would be the code and where do I enter it? I know how to get to event procedure and all.

Let me know guys, thanks!
Dec 28 '06 #6
willakawill
1,646 1GB
Ok so how do I do this? All I want is the first field to be visible and defaulted to "No" and the second field to be invisible by default but if the first field is "Yes" I want it to appear and become mandatory.

I created the fields so lets assume I have Field1 and Field2 what would be the code and where do I enter it? I know how to get to event procedure and all.

Let me know guys, thanks!
Seems like you have ignored the answers above.
What does mandatory mean?
Dec 28 '06 #7
Cyberdyne
627 Expert 512MB
I didn't ignore the answers I plugged them in the code but it did nothing

Mandatory meaning that I have to chose one of the options in Field2 in order to continue to next client.
Dec 28 '06 #8
willakawill
1,646 1GB
I didn't ignore the answers I plugged them in the code but it did nothing

Mandatory meaning that I have to chose one of the options in Field2 in order to continue to next client.
OK. Could you post your code with the plugged in items included please?
Dec 28 '06 #9
Cyberdyne
627 Expert 512MB
I will pm you the code
Dec 28 '06 #10
willakawill
1,646 1GB
I will pm you the code
Please do not pm code. It is not useful to others who want to learn from solutions to problems.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3.  
  4. Private Sub ContactTypeID_NotInList(NewData As String, Response As Integer)
  5. MsgBox "Double-click this field to add an entry to the list."
  6. Response = acDataErrContinue
  7. End Sub
  8. Private Sub ContactTypeID_DblClick(Cancel As Integer)
  9. On Error GoTo Err_ContactTypeID_DblClick
  10. Dim lngContactTypeID As Long
  11.  
  12. If IsNull(Me![ContactTypeID]) Then
  13. Me![ContactTypeID].Text = ""
  14. Else
  15. lngContactTypeID = Me![ContactTypeID]
  16. Me![ContactTypeID] = Null
  17. End If
  18. DoCmd.OpenForm "Contact Types", , , , , acDialog, "GotoNew"
  19. Me![ContactTypeID].Requery
  20. If lngContactTypeID <> 0 Then Me![ContactTypeID] = lngContactTypeID
  21.  
  22. Exit_ContactTypeID_DblClick:
  23. Exit Sub
  24.  
  25. Err_ContactTypeID_DblClick:
  26. MsgBox Err.Description
  27. Resume Exit_ContactTypeID_DblClick
  28. End Sub
  29. Private Sub Calls_Click()
  30. On Error GoTo Err_Calls_Click
  31. If IsNull(Me![ContactID]) Then
  32. MsgBox "Enter contact information before making a call."
  33. Else
  34. DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  35. DoCmd.OpenForm "Calls"
  36. End If
  37.  
  38. Exit_Calls_Click:
  39. Exit Sub
  40.  
  41. Err_Calls_Click:
  42. MsgBox Err.Description
  43. Resume Exit_Calls_Click
  44. End Sub
  45. Private Sub Dial_Click()
  46. On Error GoTo Err_Dial_Click
  47.  
  48. Dim strDialStr As String
  49. Dim ctlPrevCtl As Control
  50. Const ERR_OBJNOTEXIST = 2467
  51. Const ERR_OBJNOTSET = 91
  52.  
  53. DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  54.  
  55. Set ctlPrevCtl = Screen.PreviousControl
  56.  
  57. If TypeOf ctlPrevCtl Is TextBox Then
  58. strDialStr = IIf(VarType(ctlPrevCtl) > V_NULL, ctlPrevCtl, "")
  59. ElseIf TypeOf ctlPrevCtl Is ListBox Then
  60. strDialStr = IIf(VarType(ctlPrevCtl) > V_NULL, ctlPrevCtl, "")
  61. ElseIf TypeOf ctlPrevCtl Is ComboBox Then
  62. strDialStr = IIf(VarType(ctlPrevCtl) > V_NULL, ctlPrevCtl, "")
  63. Else
  64. strDialStr = ""
  65. End If
  66.  
  67. Application.Run "utility.wlib_AutoDial", strDialStr
  68.  
  69. Exit_Dial_Click:
  70. Exit Sub
  71.  
  72. Err_Dial_Click:
  73. If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Then
  74. Resume Next
  75. End If
  76. MsgBox Err.Description
  77. Resume Exit_Dial_Click
  78. End Sub
  79. Private Sub Page1_Click()
  80. Me.GoToPage 1
  81. End Sub
  82. Private Sub Page2_Click()
  83. Me.GoToPage 2
  84. End Sub
  85.  
  86. Private Sub Client_First_Name_AfterUpdate()
  87. Me![UKey] = Right(Year(Now()), 2) + Nz(DCount("*", "Case#", "UKey Like '" + Right(Year(Now()), 2) + "*'")) + 1
  88. End Sub
  89.  
  90. Private Sub cmdFind_Click()
  91.  
  92.  
  93. Me.Recordset.FindFirst "[Client LN] = " & Nz(Me!txtIdFind, 0)
  94.  
  95. End Sub
  96.  
  97.  
  98.  
  99. Private Sub Is_the_case_workers_comp__BeforeUpdate(Cancel As Integer)
  100. Workers_Comp_Atty.Visible = False
  101. End Sub
  102.  
  103. Private Sub The_date_of_occurence_AfterUpdate()
  104. Me![SOL 1] = DateAdd("yyyy", 1, Me![The_date_of_occurence])
  105. Me![SOL 2] = DateAdd("yyyy", 2, Me![The_date_of_occurence])
  106. Me![SOL 6M] = DateAdd("m", 6, Me![The_date_of_occurence])
  107. End Sub
  108. Private Sub Find_Click()
  109. On Error GoTo Err_Find_Click
  110.  
  111.  
  112. Screen.PreviousControl.SetFocus
  113. DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
  114.  
  115. Exit_Find_Click:
  116. Exit Sub
  117.  
  118. Err_Find_Click:
  119. MsgBox Err.Description
  120. Resume Exit_Find_Click
  121.  
  122. End Sub
  123.  
Your code shows no sign of my suggestions being plugged in.
Would you kindly explain to us what is going on in this routine
Expand|Select|Wrap|Line Numbers
  1. Private Sub Client_First_Name_AfterUpdate()
  2. Me![UKey] = Right(Year(Now()), 2) + Nz(DCount("*", "Case#", "UKey Like '" + Right(Year(Now()), 2) + "*'")) + 1
  3. End Sub
Dec 29 '06 #11
PEB
1,418 Expert 1GB
Ok so how do I do this? All I want is the first field to be visible and defaulted to "No" and the second field to be invisible by default but if the first field is "Yes" I want it to appear and become mandatory.

I created the fields so lets assume I have Field1 and Field2 what would be the code and where do I enter it? I know how to get to event procedure and all.

Let me know guys, thanks!
Hi Cyber,

So for:
All I want is the first field to be visible and defaulted to "No" and the second field to be invisible by default
1.You create ur Field1 and Field2 As Killer suggests you as checkbox or Radio boutons
2.U click on Field1 and open the control properties
3.In the properties form u set up the default Value property to No
4.U cklick on Field2 an open the control properties
5.U set up the Visible property to False

For this part it's all!


if the first field is "Yes" I want it to appear and become mandatory.
For this part:

1.You click on Field1
2.Open the control properties
3.Go onClick property and assign event procedure
4.Type there in the white window:
Expand|Select|Wrap|Line Numbers
  1. Me!Field2.Visible=Me!Field1
  2.  
5.And ur Field2 appears or disapears in function of the value of Field1

Have a very happy new year's eve man!
and very happy year!
Dec 29 '06 #12
PEB
1,418 Expert 1GB
Please do not pm code. It is not useful to others who want to learn from solutions to problems.


Your code shows no sign of my suggestions being plugged in.
Would you kindly explain to us what is going on in this routine
Expand|Select|Wrap|Line Numbers
  1. Private Sub Client_First_Name_AfterUpdate()
  2. Me![UKey] = Right(Year(Now()), 2) + Nz(DCount("*", "Case#", "UKey Like '" + Right(Year(Now()), 2) + "*'")) + 1
  3. End Sub
This is generation of number!
that gets last numbers from the current year,
than gets what is the count of the respective key for the current year and adds 1

:)
Dec 29 '06 #13
willakawill
1,646 1GB
This is generation of number!
that gets last numbers from the current year,
than gets what is the count of the respective key for the current year and adds 1

:)
Oh dear Mr PEB
I do not want to know what this code snippet does. I can see that for myself. I wanted to know if cyberdyne wrote this code or not. I have my doubts

Anyway, PEB, now that you have started I will gladly leave this with you and you can write the validation code to make field2 mandatory.

Have fun :)
Dec 29 '06 #14
Cyberdyne
627 Expert 512MB
Hey Guys, the code is cool, I love it when PEB explains things its so straightforward!

Willa the year generation code is to calculate the statue of limitations so once I enter data like 01.01.2007 the statue of limitations for one year will automatically show 01.01.2008 Code was written by PEB because he has been helping me in this first project in access.

Thanks for your help I will try the code and tell you if it works.

Best luck to you all.

Cyberdyne.
Jan 3 '07 #15
Cyberdyne
627 Expert 512MB
How do I make row source appear in my checkbox?
Jan 4 '07 #16
NeoPa
32,556 Expert Mod 16PB
What do you mean Cyber?
Are you referring to the 'Control Source' by any chance?
Jan 4 '07 #17
Cyberdyne
627 Expert 512MB
Ok I got it now

How can I make field 2 Mandatory? In other words I want it to have a value that a person will choose from the list, but if you don't choose you can't proceed.

let me know thanks
Jan 4 '07 #18
Killer42
8,435 Expert 8TB
Ok I got it now

How can I make field 2 Mandatory? In other words I want it to have a value that a person will choose from the list, but if you don't choose you can't proceed.

let me know thanks
My guess is you will just need to code that yourself. Probably something like...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.   ' If your Field1 checkbox is ticked Then
  3.     ' If you don't like the contents of field2 Then
  4.       Cancel = True
  5.       MsgBox "Get it right, dopey!"
  6.     ' End If
  7.   ' end If
  8. End Sub
Jan 4 '07 #19
Cyberdyne
627 Expert 512MB
My guess is you will just need to code that yourself. Probably something like...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.   ' If your Field1 checkbox is ticked Then
  3.     ' If you don't like the contents of field2 Then
  4.       Cancel = True
  5.       MsgBox "Get it right, dopey!"
  6.     ' End If
  7.   ' end If
  8. End Sub

Where would I insert this code? In Field1 or Field2 and where in those fields?

So I will right click on the field go to properties go to Event and then in Before Update I will go in to the code and copy and paste that code?
Jan 5 '07 #20
Killer42
8,435 Expert 8TB
Where would I insert this code? In Field1 or Field2 and where in those fields?

So I will right click on the field go to properties go to Event and then in Before Update I will go in to the code and copy and paste that code?
No, this is the BeforeUpdate event for the form. If this is the correct place for it (it was just a suggestion, after all) you would need to set the Before Update event on the form to [Event Procedure]. Then click the ... to go to the code editor, and insert this code. Note that the procedure declaration (the Private Sub and End Sub lines) will already be filled in, so skip those.

Also, I hope you realise that this code won't run as-is. A lot of it is made up of comments simply showing where to put your code. For example, where it says ' If your Field1 checkbox is ticked Then you need to put the code to test the checkbox.
Jan 5 '07 #21
Cyberdyne
627 Expert 512MB
I got it, its working fine, I am able to make it appear once I check field one. For some reason its still not mandatory though, I can still continue onto the next entry without the "Please Enter the name of the User for Field 2"

Any suggestions?
Jan 10 '07 #22
Killer42
8,435 Expert 8TB
I got it, its working fine, I am able to make it appear once I check field one. For some reason its still not mandatory though, I can still continue onto the next entry without the "Please Enter the name of the User for Field 2"
Can you post the code, so we can see exactly how you implemented it? It usually turns out to be some teeny little detail that's slightly different, so you need to see the actual code to find it.
Jan 10 '07 #23
Hope I understand you correctly: Lets add Field3, Field4 and Field5
Set Field2-5 to

Enabled=False
Locked=True
'and
Me.Field1="No"

then on AfterUpdate event of Field1 put this:
Expand|Select|Wrap|Line Numbers
  1. If me.Field1.value="Yes" then
  2.  me.Field2.Enabled=True
  3.  me.Field2.Locked=False
  4. else
  5.  me.Field2.Enabled=false
  6.  me.Field2.Locked=true
  7. end if
then put this on AfterUpdate event of Field2:
Expand|Select|Wrap|Line Numbers
  1. If not isnull(me.field2) then
  2. ' enable and unlock the rest of the fields
  3. end if
The above will really force the user user to enter value in Field2 before going to other fields but if the user select "No" then no data entry will happen or just the Field1 will be filled-in.

HTH,
George



I have two fields

Field1 - has options Yes or No
Field2 - has three options to chose from

First: What do I need to do to make Field1 be No and Field2 not selectable by default?

Second: If Field1 is selected as Yes I want Field2 to become selectable and mandatory.

Let me know, Cyberdyne.
Jan 11 '07 #24

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: MT | last post by:
Hi all, this sounds like an easy enough thing to do, but after spending 45 minutes searching google and various javascript sites I can't find out how to make a textfield (textbox or whatever you...
0
by: Dilip | last post by:
hi all , i m trying to make such a tree view which specify some folder structure for installation i mean there is some folders mandatory. This is installation software. is based upon user...
1
by: danibecr | last post by:
Hello all, I have a form that contains a remarks field for user input and a checkbox for out of compliance orders. I need to make the remarks field mandatory after the checkbox is checked. Right...
11
by: plumba | last post by:
Hi I have a user enolment form which is users fill out to let IT know that they need setting up on 'x' systems. When the user put a cross in the 'I would like Email' checkbox I would like the...
1
by: AR123 | last post by:
The mandatory form field that is not working is the TYPE OF ILLUSTRATION. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Proforma</title> <meta...
2
by: AR123 | last post by:
Hi I have set up a form. What I want to to is with the fields: Company Postcode Agency Number Policy Number I want these to be mandatory however if someone fills in the company postcode for...
3
by: Gaurav Jhamb | last post by:
I have 2-3 forms.On my first form when i serach to put any word it sends results and after that i click on new button in my search i got different organisation names. on the secong form i passed the...
7
by: sva0008 | last post by:
Hi , I have a scenario in which i have four input fields in asp with the same name batchlist. I have a button called add batch . The user can add the batch by clicking the add batch button . out...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.