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

Help with Module 3

Status
Not open for further replies.

jdwm2310

Technical User
Jul 26, 2001
396
US
I am not too familar with Modules, hope you guys can help me on this one...........
I have two forms, but a user can only fill out one form ok.
I have an employee form that has a combobox which allows the user to select either >170K or <170K. I also have two seperate forms for these selections.

Now I want a module that if the user selects >170K the form >170K should appear. I would appreciate any suggestions.
 
I don't think you need a module. (Actually I don't even think you need 2 forms, but without seeing the database design I can't be sure.)

Ok, you currently have 3 forms: FormA, with a combo box on it and FormUnder170 and FormOver170.

Just put some code in FormA, either in a button click event or a combo box event, whatever is appropiate to open the correct form. Something like this:

if me!combo > 170k then
docmd.openform &quot;FormOver170&quot;
else
docmd.openform &quot;FormUnder170&quot;
end if Maq B-)
<insert witty signature here>
 
I inseted the code you provided and I am getting a compile error: Expected:Go to or Then.

Here is what I did, I copied the code in a command button:

Private Sub Command78_Click()
On Error GoTo Err_Command78_Click

If Me.SESP_Enrollment select Above 170 Then
DoCmd.OpenForm &quot;FormAbove170&quot;
Else
DoCmd.OpenForm &quot;FormBelow170&quot;
End If
End Sub
 
Try this:

If Me.SESP_Enrollment > 170 Then
Maq B-)
<insert witty signature here>
 
This is what I have and now it's saying Type Mismatch


If Me![SERP Enrollment Selection] > 170 Then
DoCmd.OpenForm &quot;FormAbove170&quot;
Else
DoCmd.OpenForm &quot;FormBelow170&quot;
End If
 
Then it sounds like your [SERP Enrollment Selection] field isn't a number.
I don't know what values are possible in your combo box. I assumed that you were entering a number in the box, but it sounds like that isn't the case based on the error you received. You will have to modify the If statement and openform statements to whatever is appropiate for your database. The code I gave you wasn't meant to be used verbatim. You will have to tweak it to fit your data.

Maq B-)
<insert witty signature here>
 
Ok now it's working perfectly because I changed the data type to number. Now I want the form to be in Add mode..Is this possible


 
Add these lines at the end

If Me![SERP Enrollment Selection] > 170 Then
DoCmd.OpenForm &quot;FormAbove170&quot;
DoCmd.GoToRecord , , acNewRec 'add this
Else
DoCmd.OpenForm &quot;FormBelow170&quot;
DoCmd.GoToRecord , , acNewRec 'add this
 
Using this coding how can I preview the form

If Me![SESP Enrollment] > 170 Then
DoCmd.OpenForm &quot;Above 170&quot;
Else
DoCmd.OpenForm &quot;Below 170&quot;
End If

If Me![SESP Enrollment] > 170 Then
DoCmd.OpenForm &quot;SESP 2001 Above 170&quot;
DoCmd.GoToRecord , , acNewRec 'add this
Else
DoCmd.OpenForm &quot;SESP 2001 Below 170&quot;
DoCmd.GoToRecord , , acNewRec 'add this
End If
 
Guys,

I would like to view the above form in read-only mode?? Any suggestions as how to approach this. Thanks
 
I don't understand what you're trying to do. Do you want your users to be able to key data into the form or not?

If your form is supposed to be display only then you can just lock and disable all the controls on the form (set the lock and enabled properties) and set the allowadditions and allowdeletions properties of the form to no. Maq B-)
<insert witty signature here>
 
Maquis

Let me explain, the users all have a switchboard with two options: Employee Profile and Managing Benefits Plan.

the Employee Profile is intended to provide the employees via email with their information but it's in read only mode. Purpose is soley for reviewing their elections no editing.

the Managing Benefits Plans is for the users to create/ change any form.

Now I have 2 sets of forms one for the employees and the other for the users. I already created the coding for the users' form as seen above. But now I want to create a preview or read only mode for the employees' form, using the same coding as above (if possible).

I hope I made somewhat of sense, if not I will give it another try...
 
You can use the same forms for both purposes. When someone requests to see a form, check to see if they are an employee (read only) or a data keyer.

If you determine that it should be read-only, On the on_open event of your form, set the properties of all your textboxes, comboboxes, listboxes, etc. Should be txtbox1.locked = true and txtbox1.enabled = false.

If you have any command buttons on the form that the read-only folks shouldn't be clicking, disable those as well.

This should be enough to make the form read-only. Maq B-)
<insert witty signature here>
 
Could you please explain:

&quot;On the on_open event of your form, set the properties of all your textboxes, comboboxes, listboxes, etc. Should be txtbox1.locked = true and txtbox1.enabled = false.&quot;

On the on_open event procedure of my form I eneter this statement for every textboxes, comboboxes, listboxes, etc.

Like this:

Private Sub Form_Open(Cancel As Integer)

Employee Name.locked = true and Employee Name.enabled =false
Salary Below.locked = true and Salary Below.enabled= false

End Sub
 
The commands need to be on separate lines and they need to reference valid control names on your form. Are your textbox names &quot;Employee Name&quot; and &quot;Salary below&quot;? If so, just stick &quot;me!&quot; in front of them so that Access recognizes that the fields are on the current form. If your field names have spaces in them then you need to enclose them in brackets.

Here's a hint. type me!fieldname. and if <fieldname> is a valid field then when you type the &quot;.&quot;, a list of properties will pop up for you to choose from.

Private Sub Form_Open(Cancel As Integer)
me![Employee Name].locked = true
me![Employee Name].enabled =false
me![Salary Below].locked = true
me![Salary Below].enabled= false
End Sub Maq B-)
<insert witty signature here>
 
Now I have another issue, I want to preview the form of the specific individual.
This is what I have but it doesn't seem to work....Any suggestions

If Me![SESP Enrollment] > 170 Then
DoCmd.OpenForm &quot;SESP Enrollment (Above 170K)&quot;
DoCmd.GoToRecord , , acGoTo
Else
DoCmd.OpenForm &quot;SESP Enrollment (Below 170K)&quot;
DoCmd.GoToRecord , , acGoTo
End If

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = &quot;&quot;[don't know what form to add here???]&quot;

stLinkCriteria = &quot;[Employee Information]=&quot; & &quot;'&quot; & Me![Employee Information] & &quot;'&quot;
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
 
I inserted this code but I get a Run-time error '2489'

Dim stLinkCriteria As String
stLinkCriteria = &quot;[Employee Information]=&quot; & &quot;'&quot; & Me![Employee Information] & &quot;'&quot;

If Me![SESP Enrollment] > 170 Then
DoCmd.OpenForm &quot;SESP Enrollment (Above 170K)&quot;
DoCmd.GoToRecord , stLinkCriteria, acGoTo
Else
DoCmd.OpenForm &quot;SESP Enrollment (Below 170K)&quot;
DoCmd.GoToRecord , stLinkCriteria, acGoTo
End If
 
I definitely need someone to help me with this, please :cool:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top