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

Form help to require specific info based upon entry

Status
Not open for further replies.

ATCal

MIS
Apr 1, 2000
308
US
Not a true programmer, so I will explain as best as I can.

I have an existing license order form. One of the dropdowns is the "license type" with one of the options being "eval".
My goal is that if a user chooses "eval" a box pops up (or a greyed out box becomes active) that will require them to enter a date range.

The form works fine with everything in a manual mode (without the magic).

If this is too complicated to explain, then perhaps some hints on what I should be researching.

Thanks for any assistance.



Al


 
All I need to know at this point is whether or not your control that pulls up the license type is based on an ID number or if it returns text.

If it returns text, then something like this is what you need:
Code:
[COLOR=blue]
Sub [/color]LicenseType_AfterUpdate()
     [COLOR=blue]If [/color]Me.LicenseType.Value = "eval" Then
          Me.dtStart.Enabled = [COLOR=blue]True[/color]
          Me.dtEnd.Enabled = [COLOR=blue]True[/color]
     [COLOR=blue]Else[/color]
          Me.dtStart.Enabled = [COLOR=blue]False[/color]
          Me.dtEnd.Enabled = [COLOR=blue]False[/color]
     [COLOR=blue]End If
End Sub[/color]

If your combo returns a number then it will be something like this:
Code:
[COLOR=blue]
Sub [/color]LicenseType_AfterUpdate()
     [COLOR=blue]If [/color]Me.LicenseType.Value = 1 Then
          Me.dtStart.Enabled = [COLOR=blue]True[/color]
          Me.dtEnd.Enabled = [COLOR=blue]True[/color]
     [COLOR=blue]Else[/color]
          Me.dtStart.Enabled = [COLOR=blue]False[/color]
          Me.dtEnd.Enabled = [COLOR=blue]False[/color]
     [COLOR=blue]End If
End Sub[/color]

The code above assumes several things:
[ul][li]You have a combo box named [!]LicenseType[/!] (note the lack of space between License and Type}[/li]
[li]You have controls named [!]dtStart[/!] and [!]dtEnd[/!] (for your date range)[/li]
[li]That if you are referencing an ID number, that [!]1[/!] is the value of the "eval" list item.[/ul]


If you need help making sense of the code, or customizing it, let me know.

Hope this helps!

Tom

Born once die twice; born twice die once.
 
Tom,

Thanks so much for your quick response. Yes I do return text, so the top sample should be correct.

Still not sure if I even know where to put this, but I will give it a shot!

Thanks,

-Al

Al


 
Ok.

Please note the code that is existing. How/where I can insert the code you provided?
FYI- Sale_Type is the "LicenseType"
Valid_From and Valid_To are your dtStart and dtEnd

Many thanks!!

Option Compare Database

Private Sub Command10_Click()
'On Error GoTo Null_EMAIL_Err
Dim R4objPDFGen 'Perl code to generate pdfs
Dim objpdfsec 'object for pdf lockdown
Dim rslt
Dim strErrMsg As String 'for error handling
Dim R4olapp As New Outlook.Application
Dim R4olmail As Outlook.MailItem
Dim R4curcon As New ADODB.Connection
Dim R4dbs As Database, R4rst As DAO.Recordset, R4rso As DAO.Recordset
Dim intLoop As Integer
Dim i As Integer
Dim rec As String
Dim MsgResult As VbMsgBoxResult
Dim stDocName1 As String
Dim stDocName2 As String
Dim stPDF As String
Dim BCCaddr As String
Dim subject As String




If IsNull(End_User) = True Or IsNull(LSN_Type) = True Or IsNull(SN) = True Or IsNull(Email) = True Or IsNull([Sale_Type]) = True Or IsNull([PO_no]) = True Or IsNull(SO_DATE) = True Or IsNull(order_no) = True Or IsNull() = True Or IsNull([Users]) = True Or IsNull([PackType]) = True Or [Users] = 0 Or IsNull([Customer]) = True Or IsNull([contact]) = True Then
MsgBox "The information you provided is invalid.", vbExclamation, "Invalid Data"



Else



i = 1
intLoop = Me![Users]

For i = 1 To intLoop
Set R4dbs = CurrentDb
Set R4rst = R4dbs.OpenRecordset("SELECT * FROM LSN4_AVAILABLE", dbOpenDynaset)

'If IsNull(Me!Email) = True Then
' GoTo Null_EMAIL_Err
'End If
With R4rst
.Edit
![LSN_Type] = Me![LSN_Type]
![Lic_Type] = Me![LicenseType]
![No_of_Users] = Me![PackType]
![Serial_No] = Me![SN]
![Netilla_Order_No] = Me![order_no]
![Purchase_Order_No] = Me![PO_no]
![Sales_Order_Date] = Me![SO_DATE]
![Sale_Type] = Me![Sale_Type]
![End_User] = Me![End_User]
![Reseller_ID] = Me![Customer]
![Reseller_Contact] = Me![contact]
![LSN_Issue_Date] = date
![Netilla_Log_Date] = Now()
![Reseller_E_mail] = Me![Email]
![Issued_By] = CurrentUser()
![Valid_From] = Me![Valid_From]
![Valid_To] = Me![Valid_To]

.Update
End With
R4rst.Close


Al


 
Hi -
Maybe I misunderstood [smile]!

From this:
Code:
([Sale_Type]) = True

I would think that Sale_Type returns a boolean (True/False, Off/On, Yes/No, -1,0) so I'm not sure what's going on here. How can Sale_Type = LicenseType when the test for LicenseType is "eval" (which is text not boolean)?

Am I off base?

Tom

Born once die twice; born twice die once.
 
The only one off base was me.
I understood less than I could put into text.

I didn't even know where to create an AfterUpdate event.

I was eventually able to figure it out incorporating your example.

Thanks for the assistance!

-Al

Al


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top