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

Capturing data from forms to tables.

2
Hello all, I have just joined this forum in hopes of receiving some MS Access help. I have a form that when opened displays data retrieved from a query. Also on this same form, I have some text boxes for users select from a drop down and/or enter text. I am wanting to take the record displayed on the form from the query and the information enter by the user and create a record on a separte table?
Sep 6 '07 #1
3 1611
JConsulting
603 Expert 512MB
Hello all, I have just joined this forum in hopes of receiving some MS Access help. I have a form that when opened displays data retrieved from a query. Also on this same form, I have some text boxes for users select from a drop down and/or enter text. I am wanting to take the record displayed on the form from the query and the information enter by the user and create a record on a separte table?
This is fairly involved...do you feel comfortable using VBA?

You need to outline a process as well answering these questions.

1) How will I initiate the write to the other table
2) What happens if the user changes his mind?
3) how can I change those extra fields if I want to once they get written?
4) what if the information entered is incomplete?
5) will the other table have all the columns necessary to accept the form's fields and data types?
6) how will I let my user know when the write is complete?
7) who will maintain the other table down the road if there is no form interface for it?
8) will I want a way to view the record in the other table if I click on the current record I'm on?

Just a few things to consider. :)
Otherwise, the coding part is fairly straight forward using a For Each Control in Me.Controls loop.

Let us know when you're ready.
J
Sep 7 '07 #2
Lopi
2
This is fairly involved...do you feel comfortable using VBA?

You need to outline a process as well answering these questions.

1) How will I initiate the write to the other table
2) What happens if the user changes his mind?
3) how can I change those extra fields if I want to once they get written?
4) what if the information entered is incomplete?
5) will the other table have all the columns necessary to accept the form's fields and data types?
6) how will I let my user know when the write is complete?
7) who will maintain the other table down the road if there is no form interface for it?
8) will I want a way to view the record in the other table if I click on the current record I'm on?

Just a few things to consider. :)
Otherwise, the coding part is fairly straight forward using a For Each Control in Me.Controls loop.

Let us know when you're ready.
J
I am not an expert with VBA, but I am comfortable with it and have used it quite a bit in the database referenced. Most of the VBA I have done, I have needed a little code to get me started in the right direction. Is it possible you could give me an exemple or would you need to know more about the form and table? ANy help is greatly appreciated. In the mean time I will do some research on the For Each Control in Me.Controls loop.

Thanks so much for your help.
Sep 7 '07 #3
JConsulting
603 Expert 512MB
I am not an expert with VBA, but I am comfortable with it and have used it quite a bit in the database referenced. Most of the VBA I have done, I have needed a little code to get me started in the right direction. Is it possible you could give me an exemple or would you need to know more about the form and table? ANy help is greatly appreciated. In the mean time I will do some research on the For Each Control in Me.Controls loop.

Thanks so much for your help.

This is a function I had laying around that basically harvests all the data from a form. It uses recordsets and the loop I spoke of. Take a look at it, and let me know if there are parts that you don't understand, and I'll try to help you through it.

Expand|Select|Wrap|Line Numbers
  1. Function UpdateTables(strSubForm As String)
  2. ' JT 09/29/2006 This function is used by all the Add forms. Data is collected from the forms and written to the appropriate tables.
  3.     On Error GoTo UpdateTables_Error
  4.     Dim ws As Workspace
  5.     Set ws = DBEngine(0)
  6.  
  7.     Dim strUser As String
  8.     Dim rs As DAO.Recordset
  9.     Dim f As Form
  10.     Dim c As Control
  11.     Dim i As Long
  12.     Dim strSQL As String
  13.     Dim strFormField
  14.     Dim lnID As Long
  15.     Dim strMax As String
  16.     Dim strMain As String
  17.     Dim strIDfield As String
  18.     Dim strTable As String
  19.     'JT Collect Spec entry data for the specified form
  20.     strSQL = "select * from tbl_Specs where tbl_AddForm = '" & strSubForm & "';"
  21.     Set rs = CurrentDb.OpenRecordset(strSQL)
  22.         strMain = rs.Fields("tbl_MainForm").Value
  23.         strIDfield = rs.Fields("tbl_IDField").Value
  24.         strTable = rs.Fields("tbl_Name").Value
  25.         rs.Close
  26.     Set rs = Nothing
  27.     'JT Identify the form/subform you're working with
  28.     Set f = Forms(strMain)(strSubForm).Form
  29.     strSQL = "Select * from " & strTable & ";"
  30.     'JT open the target table
  31.     'ws.BeginTrans
  32.     Set rs = CurrentDb.OpenRecordset(strSQL)
  33.         rs.AddNew
  34.         For i = 0 To rs.Fields.Count - 1
  35.             For Each c In f
  36.                 strFormField = c.Name
  37.                 If rs.Fields(i).Name = strFormField Then
  38.                     If InStr(strFormField, "Loc") And f(strFormField).Value = 0 Then
  39.                         MsgBox "Location cannot be 0. Record not saved"
  40.                         f(strFormField).SetFocus
  41.                         Exit Function
  42.                     End If
  43.                     rs.Fields(i).Value = Nz(f(strFormField).Value)
  44.                     Exit For
  45.                 End If
  46.             Next c
  47.         Next i
  48.         rs.Update
  49.     rs.Close
  50.     Set rs = Nothing
  51. end function
  52.  
J
Sep 8 '07 #4

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

Similar topics

32
by: Neil Ginsberg | last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC linked tables. I recently created a new set of tables for the app, and users are complaining that unsaved data is being...
2
by: Chris Windsor | last post by:
I hope the following describe what I'm trying to do: I have created a tool to be used by product analysts when studying different cell phone designs. Part of the tool is a set of 11 forms on a...
4
by: Bill Stock | last post by:
The few times in the past that I've loaded unbound data, I've tended to cheat and use temp tables (not really unbound) or use code for small datasets. I'm currently involved in a project that...
10
by: Doug Bell | last post by:
Hi, I have an application that has a "Data Access Class" and "User Interface Class". It is for receiving Purchase Order data from one system and pushing processed transactions to another...
0
by: mjsterz | last post by:
I've been working with VB .NET for less than a year and this is the first time I've posted on one of these groups, so let me apologize beforehand if I'm being unclear, not posting my issue...
3
by: jpr | last post by:
Hello, I know that this is not the rule but need some help. My datbase has three tables: MASTER TEMPLATES FORMS I have a form which is based on a table named MASTER. I have a primary key...
3
by: rajibnsu | last post by:
While searching for capturing video with a webcam I god the following code.It gives two errors.Says:The type or namespace name 'WebcamEventArgs' does not exit in the namespace 'WebCam_Capture' (are...
11
by: Chad | last post by:
Hi Is it possible to substitute an alternative data source (eg MySQL or SQL Server) into an existing MS-Access application?
6
by: Wesley Peace | last post by:
I hate to cross post, but I've gotten no answer yet on a problem I'm having with visual studio 2008. I've created a series of forms with controls to access a Access database tables. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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:
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,...

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.