473,406 Members | 2,390 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,406 software developers and data experts.

Simple way of always opening any form of a selected customer with his data ?

Hello everybody..

Situation :

- Customer is created on customer form (Done)
- Customer is selected on ComboBox and has to be used on ALL remaining forms to be filled until we exit to main menu, where we can select another (Done)
- Any form displays the name of the selected Customer (Done with TempVars)
- Any form that is opened has to show the data entered previously for this customer in this same form (Problem, wrong mode of using filters ??)
- Each form has to have only one record for each Customer (Problem)
Oct 7 '15 #1

✓ answered by Seth Schrock

The DoCmd.ApplyFilter command doesn't use the whole SQL SELECT statement, just the WHERE clause without the word WHERE. Try fixing that and see what happens.

Probably the easiest method that I can think of to make the same form open without any previous data the first time and then with data the second time would be the specify the DataMode argument of the DoCmd.OpenForm command to be acFormAdd for the first time you open it.

11 952
Seth Schrock
2,965 Expert 2GB
Your last two items seem to contradict each other. Can you please describe in more detail what you are trying to do?
Oct 8 '15 #2
First time you open the form for this customer, new record.
Second time you open the form, should show the info filled before, not new record.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub btn3_Click()
  3.  
  4.     If IsNull(txtClientName) Then
  5.         MsgBox ("Please select a client")
  6.     Else
  7.         DoCmd.Close acForm, "Menu Budgets"
  8.         DoCmd.OpenForm "O_2 - Avaliação Clínica Inicial" 
  9.         DoCmd.ApplyFilter "SELECT [O_2-AvaliaçãoClínicaInicial].* FROM [O_2-AvaliaçãoClínicaInicial] WHERE BID = TempVars!TempBID"
  10.  
  11.         End If
  12.  
  13. End Sub
  14.  
  15.  
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Load()
  3.  
  4.     DoCmd.Maximize
  5.     txtBID.Value = TempVars!TempBID
  6.     txtClientName.Value = TempVars!TempClientName
  7.  
  8.     Me.Form.Filter = "BID=" & Me.txtBID
  9.     Me.Form.FilterOn = True
  10.  
  11. End Sub
  12.  
  13.  
Oct 8 '15 #3
For the customer personal data, it shows the form with name, address, etc, with the data entered before.
If it's another form, ti goes to new record.
I tried to use a filter as i showed, but it doesn't always work, because everytime the form is open, it saves a record automatically, even if you're only vieweing what was entered before.
Oct 8 '15 #4
Seth Schrock
2,965 Expert 2GB
The DoCmd.ApplyFilter command doesn't use the whole SQL SELECT statement, just the WHERE clause without the word WHERE. Try fixing that and see what happens.

Probably the easiest method that I can think of to make the same form open without any previous data the first time and then with data the second time would be the specify the DataMode argument of the DoCmd.OpenForm command to be acFormAdd for the first time you open it.
Oct 8 '15 #5
Tried to upload a zip file with DB (2,58MB), shows an upload error.
Oct 9 '15 #6
So desperate... :(
The stress of the time limit to do this is making me really desperate.
Oct 9 '15 #7
Seth Schrock
2,965 Expert 2GB
Did you try what I suggested? What were the results?
Oct 9 '15 #8
Like this ?

DoCmd.ApplyFilter "BID = TempVars!TempBID"
Oct 9 '15 #9
You´re my idol, it works like a charm.
So simple, yet so powerful :D
Oct 9 '15 #10
Seth Schrock
2,965 Expert 2GB
Glad you got it. Let us know if you need help with anything else in your project (in a new thread).
Oct 9 '15 #11
The final code assigned to the button, after the customer been select on the combobox, TempVars set, went like this :

Expand|Select|Wrap|Line Numbers
  1. Private Sub btn3_Click()
  2.  
  3.    If IsNull(txtClientName) Then
  4.      MsgBox ("Please select a client")
  5.    Else
  6.      DoCmd.Close acForm, "Menu Budgets"
  7.      DoCmd.OpenForm "O_2 - Avaliação Clínica Inicial" 
  8.      DoCmd.ApplyFilter "BID = TempVars!TempBID"
  9.  
  10.    End If
  11.  
  12. End Sub
  13.  
Oct 9 '15 #12

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

Similar topics

2
by: MX1 | last post by:
Does anyone know if you can convert a form into a data access page? It looks like you can only convert tables and I have a form with some very complex calculations that I'd love to leverage via an...
4
by: Terry | last post by:
I need some help refining an MS 2000 relational databse. I have created a simple relational database using two tables, 'Student Details', 'Exam Details' and two forms, 'Input/Edit Exam Details',...
3
by: Rolan | last post by:
I need assistance regarding code needed to prevent someone from opening a form if a table field name(s) has been changed. For example, there is existing code to check for certain data based on...
2
by: helpful sql | last post by:
Hi all, I need to design a solution that will display customer data from Sql Server tables in an Internet Explorer tab of a third party app, e.g. the third party app has a tab that can display web...
3
by: pedro8ae | last post by:
If I build a form to input data into a table every time I open the form I am seeing the data I enter the last time my question is how every time I save data in my form I get a clean set of fields...
2
by: D Biegert | last post by:
While in Forms View, a coworker inadvertantly selected Records/Data Entry and it set her form back at record #1 and erased all data from Form View. She still has access to the data in the Datasheet...
3
by: nityaprashant | last post by:
hello.. i have grid view.. in that template column i want to fatch product name form selected row.. i had done code like below.. but it fatch all row's product name one by one.. i want...
1
by: Dean0621 | last post by:
Good morning folks, as with most people on here with their first time question, I have been working on this issue for nearly two weeks, doing some searching on this forum and the internet to assist...
2
by: weronika58 | last post by:
Hi guys...I need a bit of Help I need to create a simple customer data base. I then need this data base to be easy to search for people by their last and first names. I would like to be able to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
tracyyun
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...
0
agi2029
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,...

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.