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

Updating Fields on Form Open

Hi Every1

I have only just started working on databases very recently - and I am not at the technical stage yet either.

I am creating a database to integrate into sage line 50. This bit is fine, its the "user friendly" side I'm having trouble with.

I have a form with the main invoice details (which is a sub form on the customer account). I need another form to enter the invoice message and breakdown of materials and labour. I would like to add a button on the subform to open a new form but to have already entered the invoice number.

I have tried already the microsoft built in options, but that only appears to work for data which has already been entered.

I would be grately appreciative if anyone could help.

Thanks

Dan
Jul 8 '07 #1
17 1940
FishVal
2,653 Expert 2GB
Hi Every1

I have only just started working on databases very recently - and I am not at the technical stage yet either.

I am creating a database to integrate into sage line 50. This bit is fine, its the "user friendly" side I'm having trouble with.

I have a form with the main invoice details (which is a sub form on the customer account). I need another form to enter the invoice message and breakdown of materials and labour. I would like to add a button on the subform to open a new form but to have already entered the invoice number.

I have tried already the microsoft built in options, but that only appears to work for data which has already been entered.

I would be grately appreciative if anyone could help.

Thanks

Dan
Hi!

Let me straight it out. The form is opened incorrectly only on a record you've just entered, there is no problem with records entered previously. This is completely normal situation bcz Access saves new record when you move to another one or a form looses focus.

If so, the cure is easy. Just add
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdSaveRecord
before DoCmd.OpenForm ... in button_click sub.
Jul 8 '07 #2
Hi There,

Unfotunately not. Just to clarify I have 3 tables
* Invoice (Main details that I export to Sage)
* Invoice Details (main text string)
* Invoice Breakdown

These are all linked by the invoice number. I have created a form with the account details, and as a subform from that has the main invoice details. In the subform I have added a button using the access wizards to open a form (invoice details and invoice breakdown as a subform). But it does not link the invoice to the invoice details form.

Thanks for your help with this!

Dan
Jul 8 '07 #3
FishVal
2,653 Expert 2GB
Hi There,

Unfotunately not. Just to clarify I have 3 tables
* Invoice (Main details that I export to Sage)
* Invoice Details (main text string)
* Invoice Breakdown

These are all linked by the invoice number. I have created a form with the account details, and as a subform from that has the main invoice details. In the subform I have added a button using the access wizards to open a form (invoice details and invoice breakdown as a subform). But it does not link the invoice to the invoice details form.

Thanks for your help with this!

Dan
Plz post the sub handling button_click event.
Jul 8 '07 #4
Plz post the sub handling button_click event.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command23_Click()
  2. On Error GoTo Err_Command23_Click
  3.     Dim stDocName As String
  4.     Dim stLinkCriteria As String
  5.   stDocName = "002b Transaction Details"
  6.     stLinkCriteria = "[Invoice Ref]=" & "'" & Me![Invoice No] & "'"
  7.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  8. Exit_Command23_Click:
  9.     Exit Sub
  10. Err_Command23_Click:
  11.     MsgBox Err.Description
  12.     Resume Exit_Command23_Click
  13. End Sub
Jul 9 '07 #5
FishVal
2,653 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command23_Click()
  2. On Error GoTo Err_Command23_Click
  3. Dim stDocName As String
  4. Dim stLinkCriteria As String
  5. stDocName = "002b Transaction Details"
  6. stLinkCriteria = "[Invoice Ref]=" & "'" & Me![Invoice No] & "'"
  7. DoCmd.OpenForm stDocName, , , stLinkCriteria
  8. Exit_Command23_Click:
  9. Exit Sub
  10. Err_Command23_Click:
  11. MsgBox Err.Description
  12. Resume Exit_Command23_Click
  13. End Sub
Is [Invoice No] text type field in table?
Jul 9 '07 #6
Is [Invoice No] text type field in table?
Yes, the invoice number is manually entered. This links the two tables 001 Transaction Details (Invoice data to sage) and 002 Transaction Details (Invoice Breakdown)
Jul 9 '07 #7
FishVal
2,653 Expert 2GB
Yes, the invoice number is manually entered. This links the two tables 001 Transaction Details (Invoice data to sage) and 002 Transaction Details (Invoice Breakdown)
This definitely should work. Tell me please what you've actually meant in msg#1 ?

I have tried already the microsoft built in options, but that only appears to work for data which has already been entered.
Does this mean that problem occurs with new entries only?
Just to make a sence.
Jul 9 '07 #8
This definitely should work. Tell me please what you've actually meant in msg#1 ?



Does this mean that problem occurs with new entries only?
Just to make a sence.
Sorry, I'm quite confused with all this!

On opening the new form and entering information. The info goes into the new table but not in the connecting fields ie the invoice number.

The fields are there with the information, but on re-opening the form it does not show relevant data because it isnt automatically updating the invoice number in the next table.
Jul 10 '07 #9
FishVal
2,653 Expert 2GB
Ok. Sorry, I had to realize it from the very beginning. Try the following code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command23_Click()
  2.  
  3.     On Error GoTo Err_Command23_Click
  4.  
  5.     Dim stDocName As String
  6.     Dim stLinkCriteria As String
  7.  
  8.     stDocName = "002b Transaction Details"
  9.     stLinkCriteria = "[Invoice Ref]=" & "'" & Me![Invoice No] & "'"
  10.  
  11.     With DoCmd
  12.         .RunCommand acCmdSaveRecord
  13.         .OpenForm stDocName, , , stLinkCriteria
  14.     End With
  15.  
  16.     Forms![002b Transaction Details]![Invoice Ref].DefaultValue = Me![Invoice No]
  17.     ' Assuming form [002b Transaction Details] 
  18.     ' has control named [Invoice Ref] bound to [Invoice Ref] table field
  19.  
  20. Exit_Command23_Click:
  21.     Exit Sub
  22. Err_Command23_Click:
  23.     MsgBox Err.Description
  24.     Resume Exit_Command23_Click
  25.  
  26. End Sub
Jul 10 '07 #10
Ok. Sorry, I had to realize it from the very beginning. Try the following code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command23_Click()
  2.  
  3.     On Error GoTo Err_Command23_Click
  4.  
  5.     Dim stDocName As String
  6.     Dim stLinkCriteria As String
  7.  
  8.     stDocName = "002b Transaction Details"
  9.     stLinkCriteria = "[Invoice Ref]=" & "'" & Me![Invoice No] & "'"
  10.  
  11.     With DoCmd
  12.         .RunCommand acCmdSaveRecord
  13.         .OpenForm stDocName, , , stLinkCriteria
  14.     End With
  15.  
  16.     Forms![002b Transaction Details]![Invoice Ref].DefaultValue = Me![Invoice No]
  17.     ' Assuming form [002b Transaction Details] 
  18.     ' has control named [Invoice Ref] bound to [Invoice Ref] table field
  19.  
  20. Exit_Command23_Click:
  21.     Exit Sub
  22. Err_Command23_Click:
  23.     MsgBox Err.Description
  24.     Resume Exit_Command23_Click
  25.  
  26. End Sub
Thanks so much! After a little playing around I got it working - I just took the ".defaultvalue" out of line 16.

Again thanks so much!
Jul 12 '07 #11
FishVal
2,653 Expert 2GB
Thanks so much! After a little playing around I got it working - I just took the ".defaultvalue" out of line 16.

Again thanks so much!
Hi!
I'm glad you've made it work. I just want to straight out something.

Solution with .DefaultValue setting emulates Access Form/Subform relationships:
  • allows to add multiple records with the same FK value
  • does not create a new record before user has entered data

Your solution with .Value setting:
  • creates a new record when Form2 is opened, if a user will not enter a data, then an empty record will be saved to table, you should take care to delete this record
  • does not allow to add multiple records with the same FK value
Jul 13 '07 #12
Hi!
I'm glad you've made it work. I just want to straight out something.

Solution with .DefaultValue setting emulates Access Form/Subform relationships:
  • allows to add multiple records with the same FK value
  • does not create a new record before user has entered data

Your solution with .Value setting:
  • creates a new record when Form2 is opened, if a user will not enter a data, then an empty record will be saved to table, you should take care to delete this record
  • does not allow to add multiple records with the same FK value
Hi There

I've just noticed the fact it creates empty records. When ".DefaultValue" is in the code #Name? appears in the invoice reference field?

It only appears to work without .DefaultValue.

Any ideas?

Thanks

Dan
Jul 13 '07 #13
FishVal
2,653 Expert 2GB
Hi There

I've just noticed the fact it creates empty records. When ".DefaultValue" is in the code #Name? appears in the invoice reference field?

It only appears to work without .DefaultValue.

Any ideas?

Thanks

Dan
Post your sub as it looks now.
Jul 13 '07 #14
Post your sub as it looks now.
Since last spoke re-arranged a bit (forms different names etc)
Expand|Select|Wrap|Line Numbers
  1.  Private Sub Command12_Click()
  2.  
  3.     On Error GoTo Err_Command12_Click
  4.  
  5.     Dim stDocName As String
  6.     Dim stLinkCriterea As String
  7.  
  8.     stDocName = "002b Inv"
  9.     stLinkCriterea = "[InvoiceReference]=" & "'" & Me![Invoice No] & "'"
  10.  
  11.     With DoCmd
  12.         .RunCommand acCmdSaveRecord
  13.         .OpenForm stDocName, , , stLinkCriterea
  14.     End With
  15.  
  16.     Forms![002b Inv]![InvoiceReference] = Me![Invoice No]
  17.     ' Assuming form [002b Inv]
  18.     ' has control named [InvoiceReference] bound to [InvoiceReference] table field
  19.  
  20. Exit_Command12_Click:
  21.     Exit Sub
  22. Err_Command12_Click:
  23.     MsgBox Err.Description
  24.     Resume Exit_Command12_Click
  25.  
  26. End Sub
  27.  
Jul 14 '07 #15
FishVal
2,653 Expert 2GB
Since last spoke re-arranged a bit (forms different names etc)
Expand|Select|Wrap|Line Numbers
  1.  Private Sub Command12_Click()
  2.  
  3.     On Error GoTo Err_Command12_Click
  4.  
  5.     Dim stDocName As String
  6.     Dim stLinkCriterea As String
  7.  
  8.     stDocName = "002b Inv"
  9.     stLinkCriterea = "[InvoiceReference]=" & "'" & Me![Invoice No] & "'"
  10.  
  11.     With DoCmd
  12.         .RunCommand acCmdSaveRecord
  13.         .OpenForm stDocName, , , stLinkCriterea
  14.     End With
  15.  
  16.     Forms![002b Inv]![InvoiceReference] = Me![Invoice No]
  17.     ' Assuming form [002b Inv]
  18.     ' has control named [InvoiceReference] bound to [InvoiceReference] table field
  19.  
  20. Exit_Command12_Click:
  21.     Exit Sub
  22. Err_Command12_Click:
  23.     MsgBox Err.Description
  24.     Resume Exit_Command12_Click
  25.  
  26. End Sub
  27.  
Ok.
Change line #16 to
Expand|Select|Wrap|Line Numbers
  1. Forms![002b Inv]![InvoiceReference].DefaultValue = "'" & Me![Invoice No] & "'"
Jul 15 '07 #16
Ok.
Change line #16 to
Expand|Select|Wrap|Line Numbers
  1. Forms![002b Inv]![InvoiceReference].DefaultValue = "'" & Me![Invoice No] & "'"
Thats great, thanks ever so much for your help!

Dan
Jul 15 '07 #17
FishVal
2,653 Expert 2GB
Thats great, thanks ever so much for your help!

Dan
Glad you've made it work.
Jul 15 '07 #18

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

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
1
by: Old Timer | last post by:
I wish to type in a number in my "Code" field, for instance 1060, I then wish the number 1060 to trigger an event that will fill in the next field (township field) For instance, 1060 brings up and...
1
by: Harry Devine | last post by:
I have a DataGrid that is configured to use the Edit/Update/Cancel concept correctly. My grid shows values from 5 database fields. I only need to update that last 4 fields. The last field is a...
2
by: barret bonden | last post by:
(closest newsgroup I could find) Error Type: ADODB.Recordset (0x800A0CB3) Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype....
5
by: Hexman | last post by:
I've come up with an error which the solution eludes me. I get the error: >An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in HRTest.exe > >Additional...
0
by: anon1m0us | last post by:
Here is a code for ASP inputs being updated in Excel. However, when I click to submit the user, the excel does not get updated! <% @Language="VBScript" %> <% Dim con Dim rst Dim strCon Dim...
15
by: sara | last post by:
I have a Memo field in a table to hold notes from a conversation a social worker has had with a client (this is for a non-profit). If the user needs to update the memo field, I need to find the...
4
by: directory | last post by:
hey guys, I've got a weird one for ya....i have a form which takes user input in the form of textbox's etc. It then grabs some details from a file and updates some of the labels with some info...
18
omerbutt
by: omerbutt | last post by:
AJAX PROB WITH MULTIPLE RECORDS helo iam having problem in ma code will any body look out an help, i am trying t add sale record in the database and the checkthe quantity of the part slod and...
4
by: AlexNunley | last post by:
I've adopted a moderately sized (65k records) active use database (Access 2000, Windows XP). One of the most commonly used forms is whats called the RMA generation field, used to add claim...
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: 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
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
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,...
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.