How to copy the one text field into other

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
marrosskoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jonathan KellyCommented:
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
wiswalldCommented:
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
marrosskoAuthor Commented:
Thanx for reply, but Is not working. I click on cmd button and nothing happening, even the focus is not move.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

marrosskoAuthor Commented:
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
Jonathan KellyCommented:
Hi marrossko,

Have you tried my suggestion ?
0
marrosskoAuthor Commented:
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
wiswalldCommented:
Forms!frmFaults.sfrLogBook.Form.Setfocus
Forms!frmFaults.sfrLogBook.Form.txtLogName.Setfocus

0
Jonathan KellyCommented:
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
marrosskoAuthor Commented:
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
wiswalldCommented:
0
marrosskoAuthor Commented:
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
marrosskoAuthor Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jonathan KellyCommented:
cool
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.