473,408 Members | 1,938 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,408 software developers and data experts.

Need Help on Various Small Issues

I'll be brief:

Issue 1:
I have a combobox search box that allows me to choose from a drop down menu of options. When one item XX is selected, it displays only the records that contain such item XX. however if I clear the search box, the records still show a reduced value of records only containing XX. I would like to return to all records when I clear the search box menu. Any ideas?

Issue 2:
On my form,
I have the undo button to remove the previous steps taken. However, I would like a simple 'clear all button'
Creating a button that, when clicked, sets all combo boxes to NULL doesn't seem to work.
I get a runtime error - you must enter a value in the "XXX" field.

Any ideas?
Aug 16 '16 #1

✓ answered by jforbes

I think you will want to do something like the following for your AfterUpdate of the ComboBox. There are other ways of doing this, this is just one way that is similar to what you were already doing:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboshiftlookup_AfterUpdate()
  2.     Dim myLookup As String
  3.     Dim lShift As Long
  4.     myLookup = " Select * from MainTableT "
  5.     lShift = Nz(Me.cboshiftlookup, 0)
  6.     If lShift > 0  Then
  7.         myLookup = myLookup & " where ([Shift] = " & lShift & ")"
  8.     End If
  9.     Me.MainTableT_subform.Form.RecordSource = myLookup
  10.     Me.MainTableT_subform.Form.Requery
  11. End Sub
  12.  
The idea is to show all records and then apply a where clause only if the users has selected something from the ComboBox.


You might want to check out this Set all form controls to null. It would be a good starting place on how to clear out all your fields.


I use Allen Browne's approach when Locking bound controls. It may seem complex at first, but it's actually pretty easy to get going and use. Pay close attention to bullet point #6, as this is pretty key to exclude controls from being locked. By locking the controls, you can open the Form in edit mode and then control through code whether or not the user can make edits.

For future reference, we try to limit a thread to only one question. It makes it easier to answer and for people to follow along when they have similar questions.

5 850
Cbold
6
Have you tried REFRESH in the on change property of the combo box?
Aug 17 '16 #2
jforbes
1,107 Expert 1GB
What is the code for your ComboBox after update event? My guess is that it will only apply a Filter when something is selected in the ComboBox, but doesn't clear the Filter when nothing is selected. Or it may be missing the refresh like Cbold has suggested.

What are you attempting to accomplish with your clear all button that an Undo won't accomplish? And by Undo, do you mean Form.Undo Method (Access): Me.Undo

If not, could you explain the situation more? Are you on a New Record when you are doing this? Are you on an Existing Record. Are you using Bound or Unbound fields? What code have you attempted?
Aug 17 '16 #3
Hey guys thanks for the responses.

With Regard to the search box:



Private Sub cboshiftlookup_AfterUpdate()
Dim myLookup As String
myLookup = " Select * from MainTableT where ([Shift] = " & Me.cboshiftlookup & ")"
Me.MainTableT_subform.Form.RecordSource = myLookup
Me.MainTableT_subform.Form.Requery
End Sub

I have not tried REFRESH. I'm not great with programming this has been a work in progress but i'll see what happens.



With respect to the undo.
I've been using the undo record using the embedded macro. I guess the issue is if they input a value from a combo box then change it, the undo will bring them back to the first input, and I would like it to be cleared completed to "start from scratch" rather than undo to the previous input.


I forgot to mention:
through my form, the user will always have access to all records and only when they hit 'add record' will they be brought to a new empty form for a new record. I was wondering how I could set up either code or perhaps another record so that the users are only able to input data on new records, with the previous records being locked unless an 'administrator' goes in an changes it. This can be done through having the previous records visible or invisible to the user I don't care I just don't want the user to be able to change the previous records.
Aug 17 '16 #4
jforbes
1,107 Expert 1GB
I think you will want to do something like the following for your AfterUpdate of the ComboBox. There are other ways of doing this, this is just one way that is similar to what you were already doing:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboshiftlookup_AfterUpdate()
  2.     Dim myLookup As String
  3.     Dim lShift As Long
  4.     myLookup = " Select * from MainTableT "
  5.     lShift = Nz(Me.cboshiftlookup, 0)
  6.     If lShift > 0  Then
  7.         myLookup = myLookup & " where ([Shift] = " & lShift & ")"
  8.     End If
  9.     Me.MainTableT_subform.Form.RecordSource = myLookup
  10.     Me.MainTableT_subform.Form.Requery
  11. End Sub
  12.  
The idea is to show all records and then apply a where clause only if the users has selected something from the ComboBox.


You might want to check out this Set all form controls to null. It would be a good starting place on how to clear out all your fields.


I use Allen Browne's approach when Locking bound controls. It may seem complex at first, but it's actually pretty easy to get going and use. Pay close attention to bullet point #6, as this is pretty key to exclude controls from being locked. By locking the controls, you can open the Form in edit mode and then control through code whether or not the user can make edits.

For future reference, we try to limit a thread to only one question. It makes it easier to answer and for people to follow along when they have similar questions.
Aug 17 '16 #5
NeoPa
32,556 Expert Mod 16PB
Tyler:
Need Help on Various Small Issues
In that case you need to ask a separate question for each issue - as per the site rules (that you're probably not familiar with yet).

The reason for that rule is well illustrated in this thread which is a right royal pain to try to follow as well as to help with.

It's too late to sort this one out as members have responded already on multiple fronts. Please remember in future though.
Aug 19 '16 #6

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

Similar topics

11
by: Bo Peng | last post by:
Dear List, It is not clear what the title means. :-) Here is the details: I need to manage a big bunch of small objects, like struct{ int a; int b; }obj;
3
by: Jeffrey | last post by:
Good day all, I have seen so many postings dealing with MS Access as a security risk and other items, yet I see now clear reason why. I would really like someone to point me in the right...
7
by: David Laub | last post by:
I have stumbled across various Netscape issues, none of which appear to be solvable by tweaking the clientTarget or targetSchema properties. At this point, I'm not even interested in "solving"...
10
by: Nemok | last post by:
Hi, I am trying to write an additive encryption algorithm in C++ that will encrypt a text by adding a random numer to each character in a string. The code looks similar to this: for(int...
10
by: Tomás | last post by:
Let's say we have a function that returns the result of subtracting seven from a given number. Would you write it as: (A) int SubtractSeven( int const x ) { return x - 7; }
2
by: VirtualLilac | last post by:
Hi, Am trying to build a database for non-profit organisation, its a volunteer job and nobody around to guide me. From my learning I could able to build few reports and forms but am feeling stuck...
2
by: Jorgen Bodde | last post by:
Hi all, This is slightly OT but it drives me nuts. Whenever I create a shortcut in the start menu (in Windows) of a python script, it will only execute it when the path where the script resides...
3
by: thallasridevi | last post by:
i want to execute a script for every 10 seconds . and the loop is 10 minutes long. I written the code like this but i got timeout warning. i have changed the execution time too in .ini file. please...
2
by: nomana123 | last post by:
#include<iostream> using namespace std; int main() {//variables defined here float angle,q; cout<<"Enter angle value "; cin>>angle;
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.