[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

How to copy the one text field into other

Posted on 2008-01-25
13
Medium Priority
?
305 Views
Last Modified: 2013-11-28
Hi experts,
i need help with my solution. I have a main form "frmFaults" and subform "sfrLogBook" In the main form I have text fields txtDate, txtName and txtPhoneNumber. In the subform I have fields txtLogName, txtLogDate and txtLogPNumber. On main form I have the command button cmdAdd.
Now what i need to do is when the cmdAdd is hit, content of the fields in main form frmFaults is copy as a new record into subform (txtDate -> txtLogDate, txtName -> txtLogName, txtPhoneNumber -> txtLogPNumber). So this way I can create the list of the log about faults. The option could be erasing the fields in the main form.

Tahnx
0
Comment
Question by:marrossko
  • 6
  • 4
  • 3
13 Comments
 
LVL 7

Expert Comment

by:Jonathan Kelly
ID: 20747908
Hi marrossko,

I would use an Append Query to achieve this.

INSERT INTO LogBook_Table ( tDate, tLogDate, tName, tLogName, tPhone, tLogPNum )
SELECT
[Forms]![frmFaults]![txtDate] AS Expr1,
[Forms]![frmFaults]![txtLogDate] AS Expr2,
[Forms]![frmFaults]![txtName] AS Expr3,
 [Forms]![frmFaults]![txtLogName] AS Expr4,
[Forms]![frmFaults]![txtPhone] AS Expr5,
[Forms]![frmFaults]![txttLogNum] AS Expr6;

Save the query as something like "AppendLogRecord"
On the On Click Event of your add button
call the query
Docmd.OpenQuery "AppendLogRecord"

You can use
Docmd.SetWarnings False to turn off the prompt.

Docmd.SetWarnings False
Docmd.OpenQuery "AppendLogRecord"
Docmd.SetWarnings True

You should probably check that each field has a valid value before you call the query.

Rgds,
Datrias
0
 
LVL 13

Expert Comment

by:wiswalld
ID: 20748252
Dim TDate, TName, TPhoneNumber

TDate = Me!TXTDate
TName = Me!TXTDate
TPhoneNumber = Me!TXTPhoneNumber

Forms!frmFaults.sfrLogBook.Form.setfocus
DoCmd.GoToRecord , , acNewRec

Me.txtLogName = TName
Me.field2 = TDate 'Change field Name
Me.Field3 = TPhoneNumber 'Change Field Name
0
 

Author Comment

by:marrossko
ID: 20750704
Thanx for reply, but Is not working. I click on cmd button and nothing happening, even the focus is not move.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

Author Comment

by:marrossko
ID: 20751477
I struggle with this...I'm trying to break-down the code step by step and I realized that I cant even move the focus from the main form to control in the subform. When i click on the cmdAdd it should move the focus into the txtText1 text field. I have this code under the cmd:

[Forms]![frmFaults]![sfrLogBook].[Form]![txtText1].SetFocus

Is there something wrong with this statement what I can not see? Please advise.
Tahnx
marrossko
0
 
LVL 7

Expert Comment

by:Jonathan Kelly
ID: 20761179
Hi marrossko,

Have you tried my suggestion ?
0
 

Author Comment

by:marrossko
ID: 20761602
Hi Datrias,
I have a problem to apply your solution. Thing is the form frmFaults using the table tblFaults and subform sfrLogBook using table tblLogFaults. But this text fields txtDate, txtName and txtPhoneNumber in the frmFaults are unbanut. Even though they are not link with table tblFaults, the content of it has to be copy/move to the proper text fields in the subform. So the query is not really a solution for my case. So I thought that something like this would help, but not:

Me.txtName = [Forms]![frmFaults]![sfrLogBook].[Form]![txtLogName]

Even if I try to move the focus on the text field txtLogName is not working. It could be some syntax error or some misspelling but I can not see it.
Eny other suggestions?

marrossko

0
 
LVL 13

Expert Comment

by:wiswalld
ID: 20771606
Forms!frmFaults.sfrLogBook.Form.Setfocus
Forms!frmFaults.sfrLogBook.Form.txtLogName.Setfocus

0
 
LVL 7

Expert Comment

by:Jonathan Kelly
ID: 20776462
Hi  marrossko:

Apologies for long delay.

The text fields do not have to be bound to form frmFaults for my solution to work.

Rgds,
Datrias
0
 

Author Comment

by:marrossko
ID: 20794435
Hi Datrias,
I tryed to create the query but I mesed-up my db. I had to go back to my back-up. I think there has to be a solution with tables. So far I can't figured-out why the hell it doesn't want to move the focus from main form into text field in subform.

marrossko
0
 
LVL 13

Expert Comment

by:wiswalld
ID: 20796925
0
 

Author Comment

by:marrossko
ID: 20863804
Why am I ask to provide my login and password for some upload??? I'm using this page for two yeras an I heve been never ask to do it!! Can you explain?
0
 

Accepted Solution

by:
marrossko earned 0 total points
ID: 20881816
So finally I figured out...This is the code, which is doing exactly what i was need it! Even I'm not very happy with it (doesn't look "pro"):
Private Sub Command168_Click()

    DoCmd.GoToControl "sfrLogBook"
    DoCmd.GoToControl "txtLogDate"
    DoCmd.GoToRecord , , acNewRec
    Forms!frmFaults!sfrLogBook.Form.txtLogDate = Forms!frmFaults.txtCaseDate
   etc.

But thanks
0
 
LVL 7

Expert Comment

by:Jonathan Kelly
ID: 20938911
cool
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question