- Private Sub Form_Open(Cancel As Integer)
-
Combo34.SetFocus
-
If DLookup("[Permission]", "RadioLog_tblValUsers", "[UserName]= '" & [Forms]![frmLogin]![txtUsername] & "'") = "mngr" Then
-
-
If DLookup("[RegionID]", "RadioLog_tblValUsers", "[UserName]= '" & [Forms]![frmLogin]![txtUsername] & "'") = 1 Then
-
Me.Combo32.RowSourceType = "Table/Query"
-
Me.Combo32.RowSource = "qryRegion1"
-
Else
-
If DLookup("[RegionID]", "RadioLog_tblValUsers", "[UserName]= '" & [Forms]![frmLogin]![txtUsername] & "'") = 2 Then
-
Me.Combo32.RowSourceType = "Table/Query"
-
Me.Combo32.RowSource = "qryRegion2"
-
Else
-
If DLookup("[RegionID]", "RadioLog_tblValUsers", "[UserName]= '" & [Forms]![frmLogin]![txtUsername] & "'") = 3 Then
-
Me.Combo32.RowSourceType = "Table/Query"
-
Me.Combo32.RowSource = "qryRegion3"
-
End If
-
End If
-
End If
-
-
Else
-
If DLookup("[Permission]", "RadioLog_tblValUsers", "[UserName]= '" & [Forms]![frmLogin]![txtUsername] & "'") = "spvr" Then
-
Me.Combo32.RowSourceType = "Table/Query"
-
Me.Combo32.RowSource = "qryHQ"
-
Else
-
If DLookup("[Permission]", "RadioLog_tblValUsers", "[UserName]= '" & [Forms]![frmLogin]![txtUsername] & "'") = "user" Then
-
Me.Combo32.RowSourceType = "table/query"
-
Me.Combo32.RowSource = "qryDistrictDefaultUser"
-
Me.Combo32.DefaultValue = DLookup("[DistrictID]", "RadioLog_tblValUsers", "[UserName]= '" & [Forms]![frmLogin]![txtUsername] & "'")
-
Me.Combo32.Locked = True
-
Else
-
Me.Combo32.RowSourceType = "Table/Query"
-
Me.Combo32.RowSource = "RadioLog_tblValDistrict"
-
End If
-
End If
-
End If
-
-
End Sub
-
I have above code written which sets the row source property for combo34(Distric tID). I use this code because the value of this combobox should be different for different users. .The form is bound to the table called RadioCallActivi ty.
Question:
Suppose I logged in as a staff user, I can see the records entered by another people but the Combo34(Distric tID) is blank. It does not show any values in it.
How to fix it?
Thanks
22 3318
Is the form frmLogIn open when this code is run?
What version/service pack are you running? Version 2003 with the SP3 service pack installed can have "disappeari ng" data if the subsequent hotfix is not applied,
Linq ;0)>
I am using SP 2. The form frmLogin is open but hidden. Is there anything else I have to consider to make it work?
THanks
Megalog 378
Recognized Expert Contributor
This is a bit confusing, especially all the nested If's..
So this works, except if you're a 'staff user'? What permission is that exactly, 'user'? If so, then your problem might be the 'Me.Combo32.Def aultValue' should be changed to 'Me.Combo32.Val ue' (in line 22)
Few suggestions by the way....
First, here's a modified version of what you posted, using ElseIf instead of all the extra If statements: - Private Sub Form_Open(Cancel As Integer)
-
Combo34.SetFocus
-
Dim txtPermission As String
-
Dim lngRegion As Long
-
-
txtPermission = DLookup("[Permission]", "RadioLog_tblValUsers", "[UserName]= '" & [Forms]![frmLogin]![txtUsername] & "'")
-
lngRegion = DLookup("[RegionID]", "RadioLog_tblValUsers", "[UserName]= '" & [Forms]![frmLogin]![txtUsername] & "'")
-
-
Me.Combo32.RowSourceType = "Table/Query"
-
If txtPermission = "mngr" Then
-
If lngRegion = 1 Then
-
Me.Combo32.RowSource = "qryRegion1"
-
ElseIf lngRegion = 2 Then
-
Me.Combo32.RowSource = "qryRegion2"
-
ElseIf lngRegion = 3 Then
-
Me.Combo32.RowSource = "qryRegion3"
-
End If
-
ElseIf txtPermission = "spvr" Then
-
Me.Combo32.RowSource = "qryHQ"
-
ElseIf txtPermission = "user" Then
-
Me.Combo32.RowSource = "qryDistrictDefaultUser"
-
Me.Combo32.DefaultValue = DLookup("[DistrictID]", "RadioLog_tblValUsers", "[UserName]= '" & [Forms]![frmLogin]![txtUsername] & "'")
-
Me.Combo32.Locked = True
-
Else
-
Me.Combo32.RowSource = "RadioLog_tblValDistrict"
-
End If
-
-
End Sub
Also, this login form should be placing all these values into global variables, instead of you having to call on the specific form itself everytime with the Dlookups.
user=staff user. they are same. Tried to using global variables but there was an error I could not solve so I replaced it with this chunk of code.
Also, user and staff user are same.
No, If I logged in as a mngr (of region 2: Districts 1,2,3,4,5), it will show every details of the previously entered records but the DistrictID. The combobox is blank. but it will show every detail, including DistrictID, for the records where DistrictID =1 or 2 or 3 or 4 or 5
I hope you understand.
Thanks for suggestions anyways!!
Megalog 378
Recognized Expert Contributor
I'd doublecheck the queries that you're assigning to the combo box to make sure they are correctly filtering your results.
Open them up in design view, specify the criteria manually (your region #'s), and make sure the data being returned is valid.
Also, in 'qryDistrictDef aultUser', make sure the first column (or whichever column you're binding your combo box to) is also the DistrictID
They are filtering records correctly.I checked it yet once more.
Also, in 'qryDistrictDef aultUser', make sure the first column (or whichever column you're binding your combo box to) is also the DistrictID
what does this mean?
Could it be a problem as this code is written in Form's open event?
Which event takes place when you exactly start to enter data?
Megalog 378
Recognized Expert Contributor
You can try shifting it to the Load event, instead of Open. And maybe remove the SetFocus command in the first line. Although I'm not sure either move will help.
The sequence of events goes:
Open - The form isnt bound to the recordset yet, this is only creating the controls
Load - Form is bound to the dataset
Current - This is triggered when loading the first record, AND everytime you move to a new record
You were right. None of it helped? I don't where should I see for it??
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Nicolae Fieraru |
last post by:
Hi All,
I am trying to change the rowsource of a combobox when I click on it. I
played with many events, associated with the form and the combobox, but
still haven't figured out what is the way of doing it.
I have a table with products, tblProducts, some of them are Active while
others are Inactive.
The form shows all the products purchased by a customer, both Active and
Inactive in a ComboBox, cbProducts.
My client wants to view all...
|
by: John Tyce |
last post by:
When a button is clicked, a date is inserted or added into a combo box like this : ComboBox.Items.Add(string) or ComboBox.Items.Insert(0,string);
Either way, the new string does not show up in the ComboBox. I get no errors or problems, it just will not work. At load time I am retrieving dates from an Oracle database and adding them to the ComboBox with out any problems. However, once the application is up and running I cannot add to the...
|
by: pei_world |
last post by:
I want to implement a key hit with enter to dropdown a combobox that is in
the datagrid. in this case I need to override its original behaviours. I
found some codes from the web. Does anyone know how to use this code? please
help!
http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_20862953.html
|
by: dbuchanan |
last post by:
ComboBox databindng Problem
== How the ComboBox is setup and used:
My comboBox is populated by a lookup table. The ValueMember is the
lookup table's Id and the DisplayMember is the text from a
corresponding field in the lookup table. In my data table we store the
ID in what I will call the 'key' field.
== Description of the desired operation:
|
by: Peter M. |
last post by:
I'm struggling with combobox databinding with something I consider a bug...
I'm binding my combobox to an array of structs. The struct exposes two
public properties, ID and Name, to be used as the
value and displaymember properties.
This works fine. My combobox contains the correct data.
However I'm also binding my SelectedValue property to a column in a
datatable. Here's where I'm lost. The combobox doesn't show the correct
| |
by: amber |
last post by:
I'm having an issue with a combobox that is making no sense to me at all.
I have a form with several comboboxes/textboxes.
The values in these boxes are based on a datarowview, which is based on a
listbox.selecteditem.
When a different item is selected in the listbox, all the fields are
repopulated with the correct data.
I have 1 combobox which is acting weird.
|
by: active |
last post by:
I tried to use a datasource with a combobox and it didn't work completely so
I build a small test that was much more straight forward then the app.
The test was to see if the combobox dropdown list displayed the correct
data.
However, although the designer shows the combobox the combobox does not
show at runtime.
If you would be so kind as to cut the code below and paste it into a form
|
by: Andrus |
last post by:
I need to enter null value from combobox to business object property.
My combobox datasource does not contain ValueMember with null value.
So I tried to create combobox which stores null to bound object when text is
deleted.
However bound object contains old value in this case.
To reproduce:
1. Run code
|
by: JTC^..^ |
last post by:
When i attempt to bind to the "Text" and "Value" property of a combobox
on a windows form the value is reset when I leave the combobox. The
comboboxes contain the correct Text and Values. I know this as the Value
property binds correctly on it own. It is only when I bind the "Text"
and "Value" that the issue occurs.
The following sample code includes my custom classes and the Form Clode.
I have several comboboxes and customer classes...
|
by: Mark |
last post by:
I have a table with a field that uses a combobox to populate values. The
Lookup tab within table design mode is the following:
Display Control Combo Box
Row Source Type Table/Query
Row Source SELECT .LastName, .FirstName, .EmployeeNumber FROM ;
Bound Column 3
Column Count 3
Column Heads Yes
Column Widths 1";1";1"
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |