Wrong data

John Sh

Active member
Local time
Tomorrow, 02:20
Joined
Feb 8, 2021
Messages
680
I have a small form with four controls, each bound to a field in a table.
The table has various fields holding publicly available information as well as the four fields that hold private information. This all on a single record.
To access the private info requires a double click on a particular control or click the "New" button.
Regardless of what record I select, the secondary form opens with info in the first non-null record. This happens to be the second record in the table.
The form itself is bound to the common table.
The code for the form is:
Code:
Option Compare Database
Option Explicit

Private Sub btnNoInfo_Click()
    isNew = False
    DoCmd.Close acForm, Me.Name
End Sub

Private Sub Form_Load()
    If isNew = True Then
        Me.btnClose.Visible = False
        Me.btnNoInfo.Visible = True
    Else
        Me.btnClose.Visible = True
        Me.btnNoInfo.Visible = False
    End If
End Sub
The calling code is:
Code:
Private Sub BtnNew_Click()
    isNew = True
    DoCmd.Close acForm, "nok"
    Me.Dirty = False
    Call locker(False)
    DoCmd.GoToRecord , , acNewRec
    Call show("Please enter data in all relevant fields", "Y", 2)
    Me.txtNameInit.SetFocus
End Sub

Public boolean isNew flags a new record.
Screenshot_43.jpg
 
Or do you mean IsNew to be a variable, in which case, please please please stop everything you're doing and learn about option explicit, variables, and typing (at least the basic principles) before trying any more development
 
Isaac> If you read my post you would see that "isNew" is, in fact, a public boolean variable. More to the point please answer my question.
Pat> You seem to have a propensity for pulling peoples code to bits without attempting to answer the question. As a"super moderator" one would expect better things from you. I have stated many times on this forum that I am a novice programmer and am here for help. Your responses are far from helpful and border on being degrading.
That said, you may have inadvertantly pointed me in the right direction. For that I thank you.
John
 

Users who are viewing this thread

Back
Top Bottom