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

Viewing Form saves record at the same time

Hello, this is my first time here at Bytes, and i'm a newbie to Access.

I'm really desperate.
Each time i enter a form, it saves a record automatically, wich is fine if it's a new record (Button "New Budget").
But for an existing record (for View/Edit Budget by BID), it´s a problema, because it´s saves the record you're editing plus another record (the one it saves entering the form).

I use a filter (Click event + Form Load):

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" ', acNormal, , , , , Me.BID
  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.  
I tried an "Before Update" event code, but it asks the user if he wants to save soon after the form loads and then asks the same question on exiting the form, "Me.Undo" doesn't work while leaving the form, don´t know what else to do, because each time you enter/view the form, a new record is saved, and it buils up to hundreds.

Thanks in advance...
Oct 7 '15 #1
4 802
Found another problema :(
Consulting an existing record on a form, sometimes it shows the first record, but replaces the old BID (Budget ID, not primary key) on that record by the new one we're using :(

I think it has something to do with the filter i'm applying on OpenForm.
Oct 7 '15 #2
jforbes
1,107 Expert 1GB
I think you want to set the default value of the field instead of setting the field's value. By setting the value it makes the new record dirty, and Access is just doing you the favor of saving a Dirty record when the focus moves away from it. By setting the default, it doesn't create a Dirty record until something is actually entered in.

I would comment out these to lines:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3.     DoCmd.Maximize
  4.     txtBID.Value = TempVars!TempBID
  5.     txtClientName.Value = TempVars!TempClientName
  6.     Me.Form.Filter = "BID=" & Me.txtBID
  7.     Me.Form.FilterOn = True
  8.  
  9. End Sub
Then set the default value for txtBID to something like this:
Expand|Select|Wrap|Line Numbers
  1. =nz(TempVars("TempBID"),0)
and the default value for txtClientName to something like this:
Expand|Select|Wrap|Line Numbers
  1. =nz(TempVars("TempClientName"),"")
Oct 7 '15 #3
Thank you for your quick answer.

The client is created on a form, then through the main menu the client is selected in a ComboBox (which sets the values of the TempVars)

These two variables are used to populate the name and ID of the client on an unbound textbox "txtClient" and his "txtBID" (Budget Identification nunmber) on each and every Form, this way the user can go from form to form always entering data for the same cliente and see his name on top, until he exits to the main menu, where the TempVars are cleared :

TempVars!TempBID
TempVars!TempClientName

The problem is that each form is a new record or has to show always previous entered data.
Oct 7 '15 #4
The Form is always "Dirty" because the present Date is set by default on one of the fields (requested by our client)
Oct 7 '15 #5

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

Similar topics

2
by: Don Sealer | last post by:
How would I have my form open every time to a new record? I'm guessing it's possible but I can't make it happen. As always thanks, Don..........
0
by: ~toki | last post by:
I need to create a control that show the parent form in design time. ErrorProvider is a good example. I don't need the ambients properties. Just the form (embeed in the list) and some user define...
7
by: MuZZy | last post by:
HI, We have a pretty large application with hundreds of forms in it. Now some of our new clients request us to make some custom screens(forms), which basicly comes to rearranging controls on our...
1
by: dk | last post by:
Any idea why the response time is slow when running a system tray app when viewing the properties form? There is one primary loop and a timer control which executes every 3minutes. Is having the...
2
by: vinay | last post by:
Hi I must be missing some obvious point, but can someone let me know how do I add a windows.forms.timer control to a form at run time Private TM as new windows.forms.time Dim sForm as for ...
22
by: Br | last post by:
First issue: When using ADPs you no longer have the ability to issue a me.refresh to save the current record on a form (the me.refresh does a requery in an ADP). We usually do this before...
27
by: Kim Webb | last post by:
I have a field on a form for project number. I basically want it to be the next available number (ie 06010 then 06011 etc). In the form I create a text box and under control source I put: =!=...
7
by: chrismaliszewski | last post by:
Hi. I created code which makes dynamically form with bounded controls for all columns. I show it to you below. My problem is, how I have to change this code to create form which record source...
1
by: goose6180 | last post by:
Scenario: Access DB sits on a network drive (available to all users by simple path) When a user creates a new test, they press a button and it creates an email with some information that is sent to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.