Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syncronizing two form for data entry

Status
Not open for further replies.

Jeddiah

Programmer
Apr 30, 2002
17
US
I was working on two forms trying to sync them for data entry, but since there are some records that don't have correspondent records I needed for form1 to create one for it when it openes. I'm not that great with programming but have peiced together a little something, something (from here and there) that I hope will work. I keep getting an error the say wrong use of null value. Can someone take a look and tell me what I'm doing worng here. This is using Access.Private Sub Command346_Click()
On Error GoTo Err_Command346_Click

Dim stDocName As String
Dim PatientID, LastName, FirstName As String
stDocName = "ClinicInfo"

'Store the calling form's (PnoneIntakeLog PatientID,
'LastName, FirstName, PatientID to add to new form ClinicInfo
'if needed.
[PatientID] = Me![PatientID]
[FirstName] = Me![FirstName]
[LastName] = Me![LastName]

'Open form2, goto the matching PatientID field

DoCmd.OpenForm stDocName, , , , acFormEdit, , PatientID]


'Find the first record in table2 (form2) that matches
DoCmd.FindRecord [PatientID], , True, , True, , True

'If the PatientID do not match (not found in table 2) then
'this must be a new record so add a new record and populate the
'listed field on form 2

If [PatientID] <> Me![PatientID] Then
DoCmd.GoToRecord , , acNewRec
Forms!stDocName![PatientID] = [PatientID]
Forms!stDocName![FirstName] = [FirstName]
Forms!stDocName![LastName] = [LastName]

End If

Exit_Command346_Click:
Exit Sub

Err_Command346_Click:
MsgBox Err.Description
Resume Exit_Command346_Click


End SubEnd Sub











 
You must test for Isnull() which really screws things up. There are a couple of ways to test for null. The quick and dirty way is to surround a variable with nz(... ) which changes a number variable null to zero and a string variable to &quot;&quot;. Fix them all rather than spending time to search out the code.

rollie@bwsys.net
 
I had a couple of good ideals, but let's say I want to go the dirty route, what format do I use to set up my varible? I have seen the nz function before how do I apply it to say the PatientID?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top