Question : Access Open Form Problem

Hi Experts,

In my main form I have created a button called 'Broadband Order'. When I click it 'SLU' form will open absolutely fine with my record in it. However, when I click new record at the bottom, notice the Customer ID has turned to '0'. However BB ID will still auto generate new ID.

May I know what's wrong with my code? You can have a look at the subform I created and try to click next record, customer ID will stay and new BB ID will be generated. That's what I looking for.

Thanks

If you look at pic1, CustomerID is circled with red, both of the ID is identical. Behind form is the subform.

In pic2, is the next record, CustomerID turned to 0.

Subform works fine but open form have that CustomerID problem.

 
 
 

 
 
Attachments:
 
database
 

Answer : Access Open Form Problem

I'm not quite sure whether I have understood the question correctly..

You appear to be asking why no customer number is displayed when you start a new record - but I think my response is - why are you expecting it to be there? Once you start a new record then you have to supply ALL the information unless you have (VBA-) coded it to auto-fill certain controls.  How would Access know that you wanted a new record for the previous customer rather than for a different customer unless you program it to do so.

If you want to repeat the last customer number then you have to add code to the form current event and create a variable to store the customer number.

SO at the top of the form module

Dim LastCustomer as long


In the form current event....

if me.newrecord then
me.customerid= lastcustomer
else
lastcustomer = me.customerid
end if



Random Solutions  
 
programming4us programming4us