marrossko
asked on
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
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
Dim TDate, TName, TPhoneNumber
TDate = Me!TXTDate
TName = Me!TXTDate
TPhoneNumber = Me!TXTPhoneNumber
Forms!frmFaults.sfrLogBook .Form.setf ocus
DoCmd.GoToRecord , , acNewRec
Me.txtLogName = TName
Me.field2 = TDate 'Change field Name
Me.Field3 = TPhoneNumber 'Change Field Name
TDate = Me!TXTDate
TName = Me!TXTDate
TPhoneNumber = Me!TXTPhoneNumber
Forms!frmFaults.sfrLogBook
DoCmd.GoToRecord , , acNewRec
Me.txtLogName = TName
Me.field2 = TDate 'Change field Name
Me.Field3 = TPhoneNumber 'Change Field Name
ASKER
Thanx for reply, but Is not working. I click on cmd button and nothing happening, even the focus is not move.
ASKER
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]![sfrLo gBook].[Fo rm]![txtTe xt1].SetFo cus
Is there something wrong with this statement what I can not see? Please advise.
Tahnx
marrossko
[Forms]![frmFaults]![sfrLo
Is there something wrong with this statement what I can not see? Please advise.
Tahnx
marrossko
Hi marrossko,
Have you tried my suggestion ?
Have you tried my suggestion ?
ASKER
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]![sfrLo gBook].[Fo rm]![txtLo gName]
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
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]![sfrLo
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
Forms!frmFaults.sfrLogBook .Form.Setf ocus
Forms!frmFaults.sfrLogBook .Form.txtL ogName.Set focus
Forms!frmFaults.sfrLogBook
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
Apologies for long delay.
The text fields do not have to be bound to form frmFaults for my solution to work.
Rgds,
Datrias
ASKER
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
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
ASKER
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
cool
I would use an Append Query to achieve this.
INSERT INTO LogBook_Table ( tDate, tLogDate, tName, tLogName, tPhone, tLogPNum )
SELECT
[Forms]![frmFaults]![txtDa
[Forms]![frmFaults]![txtLo
[Forms]![frmFaults]![txtNa
[Forms]![frmFaults]![txtLo
[Forms]![frmFaults]![txtPh
[Forms]![frmFaults]![txttL
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