Solved Subform that hides the entered record (1 Viewer)

zelarra821

Registered User.
Local time
Today, 20:00
Joined
Jan 14, 2019
Messages
229
Hi.

I have a form with a subform:
01.jpg


When I enter an article in the subform, and go to the next record, it only shows me the new record.

02.jpg


03.jpg


Before, I used this code:

Code:
Private Sub Form_AfterInsert()
    DoCmd. RefreshRecord
    DoCmd. GoToRecord,, acNewRec
    DoCmd. RefreshRecord
    DoCmd. GoToRecord,, acFirst
    DoCmd. GoToRecord,, acNewRec
    Me. Cantidad. SetFocus
    Me. Articulo. SetFocus
    If Nz(Me.Cantidad.Value, "") <> "" Then Me.Cantidad.Value = 1: Me.Cantidad.Value = 0
End Sub

But, due to a few improvements, it turns out that you give me more trouble than anything else just to show continuous logs.

In the code of the subform there is nothing weird that, in my understanding, could interfere.

What's more, I have tried several things:
  • The Data entry property is set to No.
  • I have gone through all the code in the database, and do not change that Data Entry property at any time. What I do modify is the AllowDeletions property.
  • I don't use any Requery in the subform code.
  • I have checked the height of the subform and the height of the subform detail. Here you can see it (sorry it's in Spanish, it's called "Alto"):

ScreenShot001.jpg


ScreenShot002.jpg


I have no idea why it happens.

What I don't know is if there will be any code to show x records, as it can be done in Excel.

Thanks a lot.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:00
Joined
Oct 29, 2018
Messages
13,320
Hi. I can't tell from the images you posted, but is your subform's Default View set to Continuous Form?
 

zelarra821

Registered User.
Local time
Today, 20:00
Joined
Jan 14, 2019
Messages
229
ScreenShot001.jpg


In Vista Predeterminada you can see Formularios Continuos, or Continuous Form, it's the same.

Thanks!
 

zelarra821

Registered User.
Local time
Today, 20:00
Joined
Jan 14, 2019
Messages
229
There you go. The form is F10TPV. I'm sorry that everything is in Spanish, but I can't translate everything.
There is another problem with that form. As the three fields of the main form (Ticket Code -Código de Ticket-, Date -Fecha- and Customer -Cliente-) are inserted as default values, and then passed to the subform, it does not save the main form and causes duplicate content problems. If you know how to fix it in passing, I appreciate it.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:00
Joined
Oct 29, 2018
Messages
13,320
There you go. The form is F10TPV. I'm sorry that everything is in Spanish, but I can't translate everything.
There is another problem with that form. As the three fields of the main form (Ticket Code -Código de Ticket-, Date -Fecha- and Customer -Cliente-) are inserted as default values, and then passed to the subform, it does not save the main form and causes duplicate content problems. If you know how to fix it in passing, I appreciate it.
Hi. Thanks for posting a copy of your db. When I opened that specific form, this is what I see.

1598889202336.png


So, when I go to the new record and select something from the dropdown and then tab through all the fields, this is what I get.

1598889268973.png


So, it seems like I can see more than just the "new record" row. At this point, I am not sure I understand the problem. Can you please explain it again? Thank you.
 

zelarra821

Registered User.
Local time
Today, 20:00
Joined
Jan 14, 2019
Messages
229
I have recorded a video of what is happening

 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:00
Joined
Oct 29, 2018
Messages
13,320
I have recorded a video of what is happening

Sorry, I tried, but I can't access the video from work. I'll take a look when I get home tonight.
 

zelarra821

Registered User.
Local time
Today, 20:00
Joined
Jan 14, 2019
Messages
229
I have found the error, but I do not know how to solve it.

See if I can explain it. The main form and the subform are related by IDTPV. This field is auto-numeric in the main table, and long integer in the subtable.

Since the first three fields in the main form are added as default values, it's as if they don't exist yet. In fact, if you add the IDTPV field, you can see how the registration number is not generated. When you go to the subform, the dropdown is independent, therefore, when updating it, you are not modifying any field in the subform, so it does not have an ID yet. To do this, what I have done has been to add, after updating the drop-down list, to set Quantity the value 1. In this way, it already generates the ID of the subform. But it still does not generate the IDTPV by which it is related to the main form. And this is where I don't know how to give you a solution so that, when updating the dropdown, add a record to the main form with the corresponding IDTPV and the first three fields, taking these the value of the default value.

What I am missing is to know if, after fixing that, a second record will appear below the first.
 

zelarra821

Registered User.
Local time
Today, 20:00
Joined
Jan 14, 2019
Messages
229
The problem with not displaying more than one record in the subform is because of the separate dropdown. When I map to one of the fields in the subtable, it shows me a second record as I start to enter values.

It only remains for me to fix the problem that it saves the main form.
 

zelarra821

Registered User.
Local time
Today, 20:00
Joined
Jan 14, 2019
Messages
229
I've already managed to solve it. I'll explain it around here in case someone else serves you.

The problem was indeed the combo. I had him as an independent, and he gave such strange behavior. I have linked it to a field of the subform, and fixed.

On the other hand, the problem that I did not get the records. I have solved it by putting the following in VBA:

Code:
If Me.NewRecord Then
Me.Fecha=Now
Me.CodigoTicket=myFunction
Me.CodigoCliente=2
End If

To give the user the option to delete the record that he has created, when he has done it inadvertently, I have put a button that deletes the record, like this:

Code:
Private Sub CmdBorrar_Click()
Dim ID As Integer
    ID = Me.IDTPV
    DoCmd.GoToRecord , , acFirst
    CurrentDb.Execute "DELETE * FROM T10TPV WHERE IDTPV=" & ID
    Me.Requery
    DoCmd.GoToRecord , , acLast
End Sub

As it creates a new record, I had to previously move it to the start and I can now delete it without problems.

Thank you very much.

A greeting.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:00
Joined
Oct 29, 2018
Messages
13,320
I've already managed to solve it. I'll explain it around here in case someone else serves you.

The problem was indeed the combo. I had him as an independent, and he gave such strange behavior. I have linked it to a field of the subform, and fixed.

On the other hand, the problem that I did not get the records. I have solved it by putting the following in VBA:

Code:
If Me.NewRecord Then
Me.Fecha=Now
Me.CodigoTicket=myFunction
Me.CodigoCliente=2
End If

To give the user the option to delete the record that he has created, when he has done it inadvertently, I have put a button that deletes the record, like this:

Code:
Private Sub CmdBorrar_Click()
Dim ID As Integer
    ID = Me.IDTPV
    DoCmd.GoToRecord , , acFirst
    CurrentDb.Execute "DELETE * FROM T10TPV WHERE IDTPV=" & ID
    Me.Requery
    DoCmd.GoToRecord , , acLast
End Sub

As it creates a new record, I had to previously move it to the start and I can now delete it without problems.

Thank you very much.

A greeting.
Hi. Congratulations! Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom