Hello,
Forum
I am having trouble closing my frmLogin and opening frmMaster.
When User enters wrong password. The form will close.
What I want is to close frmLogin only when User has open frmMaster
TIA
Haziq
Hello,
Forum
I am having trouble closing my frmLogin and opening frmMaster.
When User enters wrong password. The form will close.
What I want is to close frmLogin only when User has open frmMaster
TIA
Haziq
Add the red code to your btnLogin_Click event:
Also, change your frmLog code to this:Code:Else MsgBox "Login UnSuccessful!" txtPassword = vbNullString Exit Sub End If
Code:Option Compare Database Option Explicit Private Sub btnAddNewRecord_Click() Dim sSQL As String Dim nQty As Long nQty = DLookup("CurrentQty", "tblMaster", "MasterIDPK=" & MasterIDFK) Select Case Withdraw Case True If nQty - UserQty > 0 Then sSQL = "UPDATE tblMaster Set CurrentQty = CurrentQty - " & [UserQty] & " WHERE MasterIDPK = " & [MasterIDFK] End If Case False sSQL = "UPDATE tblMaster Set CurrentQty = CurrentQty + " & [UserQty] & " WHERE MasterIDPK = " & [MasterIDFK] Case Else MsgBox "No action taken, 'Withdraw' does not contain a valid entry", vbOKOnly, " I N P U T N E E D E D " Exit Sub End Select If Len(sSQL) > 0 Then CurrentDb.Execute sSQL, dbFailOnError Else MsgBox "No action taken, check your quantities for valid values", vbOKOnly, " C H E C K QTY V A L U E S " End If DoCmd.Close acForm, Me.Name End Sub
Try attached file:
If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
Bob Fitzpatrick
Also note:
EVERY code module should have these top two lines:
Code:Option Compare Database Option Explicit
After you do that, you can do a Debug/Compile and fix the errors.
You have a variable not declared, "strSection" in form "frmLogin" and a misspelled argument "dbfailonerrror" in form "frmLog".
I think you have a problem with your structure/relationships. Why is the relationship 1-to-1 between "tblDesc" and "tblMaster"??
Thank you guys for all your help.
It is working the way how I visioned it.
@ssanfu,
June7 did point this out too.
The reason is because I wanted to split the information about the item in another table.
I have not make the required adjustments.
I am going to do it now.
Btw can I append tblDesc to tblMaster?
@Bob Fitz, I saw what you did there in the tblemployees
TIA
Haziq
Yes, you could create the fields in tblMaster, then use an Append query to copy the data.
An alternative is to change the field "MasterIDFK" in tblDesc so it is NOT the PK field. (doesn't make sense to have the field as the PK field, but the field name has "FK" in it).
Delete the relationship between the two tables.
Add a new PK field (I named it DescID_PK")
Edit the field "MasterIDFK", change the Indexed property to "Yes - Duplicates OK".
Add the relationship. Now it should be 1-to-many.
Thankyou for the speedy reply.
I have combine both tables into one using make table query.
I will put to practice what you have thought me.
Thanks again.
---------------
Haziq
---------------
I am still trying