Form does not update correct record (1 Viewer)

ppataki

Registered User.
Local time
Today, 05:25
Joined
Sep 5, 2008
Messages
267
Dear All,

I have a form that shows records of a table
At one field, if the word "petrol" is entered through a combo box, a new form pops-up, asking for a number (how many litres)
The problem is that whenever this latter form is filled in with a litre, that number goes into a new record and not into the record which is being worked on (which is selected when choosing the word "petrol" in the main form)

Could you please advise on how I can make the second form put the litre in the corresponding record?

Many thanks in advance :)
 
The command button wizard has the facility to generate code to open a form. One of the options when you create this code with the command button wizard is to open a form to a new record, or to open a form to the record and matching the current record of the form you called the form from.

Once you have generated this code you should be able to adapt it to be called by the code that is triggered by the selection of "Petrol" (Gas)
 
Given the stated scenario, opening a second form just to to enter this one value sounds kind of like overkill. Why not simply use an InputBox?
Code:
Private Sub YourComboBox_AfterUpdate()
 If Me.YourComboBox = "petrol" Then
  Me.NumberOfLitres = InputBox("Enter Number of Litres", "Input Litres", "")
 End If
End Sub
 
Hello!

Thank you for the replies!
The Inputbox method works fine!

However, when trying to use the command button wizard, I cannot see the option mentioned by Uncle Gizmo, after choosing Open Form, the wizard only asks me which form I want to open, then which records I want to display, then the name of the button and that's it
Did I do something incorrectly?

Many thanks!!
 

Users who are viewing this thread

Back
Top Bottom