473,320 Members | 1,884 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,320 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 800
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.