spzbiegien
asked on
Programming & Database problem in MS ACCESS 97
I have two tables. PACC and JACC for Primary account holder and joint account holder. There is a 1:1 relationship. The PACC table primary key is ACCNUM and the JACC Table has PACC as a Foreign Key with an Autonumber index. I have two forms: Primary Account Information and Joint Account Information. I do not have any problem writing to the PACC table from the Primary Account Information Form.
Now, I have a button on the Primary Account form that displays the Joint account form. I want 3 different text boxes to display the ACCNUM, FNAME, LNAME from the PACC table on the JOINT Account Form, then I want to enter the Joint Account information into the JACC table from the JOINT Account form.
I have attached the code that writes to the Primary Account table: Becareful of the comments. You can see what I was trying to do with a SQL statement.
If more info is needed email at spzbiegien@hotmail.com
Private Sub CmdEnter_Click()
Dim dbs As Database
Dim rs As Recordset
Dim sSQL As String
Dim ACNUM As Control
'Open the current database
Set dbs = CurrentDb
Set ACNUM = [Forms]![FRMMAIN]![ACCNUM]
'Open the current recordset
'sSQL = "SELECT tblTEST.ACCNUM, tblJTEST.ACCNUM, tblTEST.ACCSTATUS, tblTEST.ACCLEAVESTATUS, tblTEST.ACCSOCIAL, tblTEST.ACCFNAME, tblTEST.ACCMI, tblTEST.ACCLNAME, tblTEST.ACCADDRESS, tblTEST.ACCCITY, tblTEST.ACCSTATE, tblTEST.ACCZIP" FROM tblTEST INNER JOIN tblJTEST ON tblTEST.ACCNUM = tblJTEST.ACCNUM;"
'Set rs = dbs.OpenRecordset("SELECT tblTEST.ACCNUM, tblJTEST.ACCNUM, tblTEST.ACCSTATUS, tblTEST.ACCLEAVESTATUS, tblTEST.ACCSOCIAL, tblTEST.ACCFNAME, tblTEST.ACCMI, tblTEST.ACCLNAME, tblTEST.ACCADDRESS, tblTEST.ACCCITY, tblTEST.ACCSTATE, tblTEST.ACCZIP FROM(tblTEST INNER JOIN tblJTEST ON tblTEST.ACCNUM = tblJTEST.ACCNUM)")
'Set rs = dbs.OpenRecordset(sSQL)
Set rs = dbs.OpenRecordset("tblTEST ")
With rs
.AddNew
!ACCNUM = [Forms]![FRMMAIN]![ACCNUM]
!ACCSTATUS = [Forms]![FRMMAIN]![ACCSTAT US]
!ACCLEAVESTATUS = [Forms]![FRMMAIN]![ACCLEAV ESTATUS]
!ACCSOCIAL = [Forms]![FRMMAIN]![ACCSOCI AL]
!ACCFNAME = UCase([Forms]![FRMMAIN]![A CCFNAME])
!ACCMI = UCase([Forms]![FRMMAIN]![A CCMI])
!ACCLNAME = UCase([Forms]![FRMMAIN]![A CCLNAME])
!ACCADDRESS = [Forms]![FRMMAIN]![ACCADDR ESS]
!ACCCITY = UCase([Forms]![FRMMAIN]![A CCCITY])
!ACCSTATE = UCase([Forms]![FRMMAIN]![A CCSTATE])
!ACCZIP = [Forms]![FRMMAIN]![ACCZIP]
.Update
.Bookmark = rs.LastModified
End With
rs.Close
'initialize the form
Call INITIALIZE
' SetFocus to text box.
ACNUM.SetFocus
End Sub
Now, I have a button on the Primary Account form that displays the Joint account form. I want 3 different text boxes to display the ACCNUM, FNAME, LNAME from the PACC table on the JOINT Account Form, then I want to enter the Joint Account information into the JACC table from the JOINT Account form.
I have attached the code that writes to the Primary Account table: Becareful of the comments. You can see what I was trying to do with a SQL statement.
If more info is needed email at spzbiegien@hotmail.com
Private Sub CmdEnter_Click()
Dim dbs As Database
Dim rs As Recordset
Dim sSQL As String
Dim ACNUM As Control
'Open the current database
Set dbs = CurrentDb
Set ACNUM = [Forms]![FRMMAIN]![ACCNUM]
'Open the current recordset
'sSQL = "SELECT tblTEST.ACCNUM, tblJTEST.ACCNUM, tblTEST.ACCSTATUS, tblTEST.ACCLEAVESTATUS, tblTEST.ACCSOCIAL, tblTEST.ACCFNAME, tblTEST.ACCMI, tblTEST.ACCLNAME, tblTEST.ACCADDRESS, tblTEST.ACCCITY, tblTEST.ACCSTATE, tblTEST.ACCZIP" FROM tblTEST INNER JOIN tblJTEST ON tblTEST.ACCNUM = tblJTEST.ACCNUM;"
'Set rs = dbs.OpenRecordset("SELECT tblTEST.ACCNUM, tblJTEST.ACCNUM, tblTEST.ACCSTATUS, tblTEST.ACCLEAVESTATUS, tblTEST.ACCSOCIAL, tblTEST.ACCFNAME, tblTEST.ACCMI, tblTEST.ACCLNAME, tblTEST.ACCADDRESS, tblTEST.ACCCITY, tblTEST.ACCSTATE, tblTEST.ACCZIP FROM(tblTEST INNER JOIN tblJTEST ON tblTEST.ACCNUM = tblJTEST.ACCNUM)")
'Set rs = dbs.OpenRecordset(sSQL)
Set rs = dbs.OpenRecordset("tblTEST
With rs
.AddNew
!ACCNUM = [Forms]![FRMMAIN]![ACCNUM]
!ACCSTATUS = [Forms]![FRMMAIN]![ACCSTAT
!ACCLEAVESTATUS = [Forms]![FRMMAIN]![ACCLEAV
!ACCSOCIAL = [Forms]![FRMMAIN]![ACCSOCI
!ACCFNAME = UCase([Forms]![FRMMAIN]![A
!ACCMI = UCase([Forms]![FRMMAIN]![A
!ACCLNAME = UCase([Forms]![FRMMAIN]![A
!ACCADDRESS = [Forms]![FRMMAIN]![ACCADDR
!ACCCITY = UCase([Forms]![FRMMAIN]![A
!ACCSTATE = UCase([Forms]![FRMMAIN]![A
!ACCZIP = [Forms]![FRMMAIN]![ACCZIP]
.Update
.Bookmark = rs.LastModified
End With
rs.Close
'initialize the form
Call INITIALIZE
' SetFocus to text box.
ACNUM.SetFocus
End Sub
pls. check your email
EE Questions should not be handled by email. If more info is needed, please post it.
https://www.experts-exchange.com/Databases/MS_Access/help.jsp#hi99
Walt
https://www.experts-exchange.com/Databases/MS_Access/help.jsp#hi99
Walt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.