Changes made to a record are reflected in the other records (Access + VBA)

Asked

Viewed 85 times

0

I created a Vehicle reservation form where I have a field where the user must enter the destination of the trip. The user may also need more than one destination, so I have created an add_destination button that makes textbox be inserted into the Form for each additional destination.

The problem is that when inserting a Textbox in Record 1 this action is reflected in all other records already registered (I only got to "if Form_newrecord = true" so that the Textbox is removed). So when I go to any other record and delete some Textbox with the del_destination button, again, the Textbox of the other records disappear together, even if it has content.

How can I avoid this problem.

Also, how can I save the Form state so that when the Text box is opened again it will be there if it has been activated?

I hope it wasn’t too confusing.

    Private Sub addPassageiro_Click()
' Botão que adiciona passageiros à requisição

If txtQtdPass < 19 Then
    cont = cont + 1
    txtQtdPass = cont
    ' checar se cont é par o ímpar
    If cont Mod 2 = 0 Then
        Me.Controls("passageiro" & cont).Top = Me.Controls("passageiro" & cont).Top + 200 * cont
        Me.Controls("passageiro" & cont + 1).Top = Me.Controls("passageiro" & cont + 1).Top + 200 * cont

        Me.Form.InsideHeight = Me.Form.InsideHeight + 400
        lblsaida.Top = lblsaida.Top + 400
        Saida.Top = Saida.Top + 400
        Destino.Top = Destino.Top + 400
        Destino1.Top = Destino1.Top + 400
        Destino2.Top = Destino2.Top + 400
        Destino3.Top = Destino3.Top + 400
        lblmoto.Top = lblmoto.Top + 400
        Motorista.Top = Motorista.Top + 400
        lblveiculo.Top = lblveiculo.Top + 400
        Veiculo.Top = Veiculo.Top + 400
        lblinfo.Top = lblinfo.Top + 400
        Infos.Top = Infos.Top + 400

    End If


Else
    MsgBox "Não é possível adicionar mais passageiros"
End If


End Sub
  • Hey Ookami, could you send me your code to help you better?

  • @Thalesferraz, Add the code to the question.

  • Hey Ookami, you are very confused because in the text you talk about adding and deleting "destinations" and in the code you have only the option to add "passengers". The problem is not to be different from destinations for passengers because it can be interpreted, but is that by its description the problem occurs when deleting and the code presented is only to add. Would you kindly add the full code?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.