Hi there tried creating new entry, it only works when the database is decompreste? weird I know.
can anyone help ?
thanks
PS: see code below - Dim HospitalNumber As String
-
Dim strSQL0 As String
-
dim LastName As String
-
Dim FirstName As String
-
Dim strDOB As String
-
-
If IsNull(Me.Text0.Value) Then
-
strHospitalNumber = " Like '*' "
-
Else
-
strHospitalNumber = "='" & Me.Text0.Value & "' "
-
End If
-
-
If IsNull(Me.Combo8.Value) Then
-
strLastName = " Like '*' "
-
Else
-
strLastName = "='" & Me.Combo8.Value & "' "
-
End If
-
-
If IsNull(Me.Combo10.Value) Then
-
strFirstName = " Like '*' "
-
Else
-
strFirstName = "='" & Me.Combo10.Value & "' "
-
End If
-
-
If IsNull(Me.DOB.Value) Then
-
strDOB = " Like '*' "
-
Else
-
strDOB = "=" & "#" & Format(Me![DOB], "mm\/dd\/yyyy") & "# "
-
End If
-
-
-
strSQL0 = "SELECT Profile.* " & _
-
"FROM Profile " & _
-
"WHERE Profile.HospitalNumber" & strHospitalNumber & _
-
"AND Profile.LastName" & strLastName & _
-
"AND Profile.FirstName" & strFirstName & _
-
"AND Profile.DOB" & strDOB & _
-
"ORDER BY Profile.PtID;"
-
-
Set rst1 = CurrentDb.OpenRecordset(strSQL0)
-
-
If rst1.EOF Then
-
-
Dim Msg, Style, Title, Response
-
-
Msg = "There are no existing records for this patient in the database. To add this patient, click 'Yes'. To cancel and close this message box, click 'no'."
-
Style = vbYesNo + vbDefaultButton2
-
Title = "Would you like to add this patient to the database?"
-
Response = MsgBox(Msg, Style, Title)
-
-
If Response = vbYes Then
-
-
rst1.Close
-
-
DoCmd.SetWarnings (WarningsOff)
-
-
Set rst2 = CurrentDb.OpenRecordset("Profile")
-
-
rst2.AddNew
-
rst2![HospitalNumber] = Me![Text0] 'the field from your form that matches the table column
-
rst2![LastName] = Me![Combo8]
-
rst2![FirstName] = Me![Combo10]
-
rst2![DOB] = Me![DOB]
-
-
rst2.Update
-
-
Dim strSQL1 As String
-
Dim rptID1 As String
-
-
strSQL1 = "Select Max([PtID]) as [MaxOfID] from Profile;"
-
-
Set rst3 = CurrentDb.OpenRecordset(strSQL1)
-
rst3.MoveFirst
-
-
rptID1 = rst3![MaxOfID]
-
-
DoCmd.SetWarnings (WarningsOn)
-
-
DoCmd.OpenForm "Profile", acNormal, , "[PtID]= " & rptID1, acFormEdit, acWindowNormal
-
-
rst2.Close
-
rst3.Close
-
-
DoCmd.Close acForm, "FindPatient", acSaveYes
-
-
Else
-
'Do Nothing
-
-
End If
-
-
-
ElseIf rst1.RecordCount = 1 Then
-
-
Dim strSQL2 As String
-
-
strSQL2 = "SELECT Profile.PtID As PatientID " & _
-
"FROM Profile " & _
-
"WHERE Profile.HospitalNumber" & strHospitalNumber & _
-
"AND Profile.LastName" & strLastName & _
-
"AND Profile.FirstName" & strFirstName & _
-
"AND Profile.DOB" & strDOB & _
-
"ORDER BY Profile.PtID;"
-
-
Set rst4 = CurrentDb.OpenRecordset(strSQL2)
-
-
rst4.MoveFirst
-
-
Dim RptID2 As String
-
-
RptID2 = rst4![PatientID]
-
-
DoCmd.OpenForm "Profile", acNormal, , "[PtID]= " & RptID2, acFormEdit, acWindowNormal
-
-
DoCmd.Close acForm, "FindPatient", acSaveYes
-
-
rst1.Close
-
rst4.Close
-
-
-
Else
-
-
Dim Msg2, Style2, Title2, Response2
-
-
Msg2 = "There are more than 1 records matching these criteria. If you would like to browse these, click 'Yes'. If you would like to enter more criteria, click 'No'."
-
Style2 = vbYesNo + vbDefaultButton2
-
Title2 = "Would you like to browse all matching records?"
-
Response2 = MsgBox(Msg2, Style2, Title2)
-
-
If Response2 = vbYes Then
-
-
DoCmd.OpenForm "Profile", acNormal, strSQL0, acFormEdit
-
'corresponding to rst1
-
-
DoCmd.Close acForm, "FindPatient", acSaveYes
-
-
Else
-
'Do Nothing
-
-
End If
-
-
rst1.Close
-
-
End If
-
-
-
End Sub
0 875 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Frogbčrt |
last post by:
Config: Win2K, IIS5.0
My solution requires that the host header sent to IIS be analyzed. I have
set up a web site that responds to both www.domain.com and domain.com. In
DNS, both a WWW and a *...
|
by: Shapper |
last post by:
Hello,
I have created 3 functions to insert, update and delete an Access
database record. The Insert and the Delete code are working fine.
The update is not. I checked and my database has all...
|
by: Mark B |
last post by:
Our webhost (www.usbusinessweb.net) had a W2K IIS5 server crash after a
scheduled hard-boot occurred during a ms-security patch install overnight.
They couldn't get the server working again so they...
|
by: HydroSan |
last post by:
Having a bit of a problem getting UPDATE working. The project in
question is a simple MySQL VB.NET frontend, allowing Insertion,
Selection, and others.
Well, I've gotten Drop and Insert working,...
|
by: Shane_SDE |
last post by:
I am attempting to use a FormView control with an ObjectDataSource. I have
the Select and Update working correctly. I tried to add a Delete Command to
either the Edit or the Item Templates and it...
| |
by: Greg P |
last post by:
I am using VS2005 and have been learning a ton about databinding. I know
that when you drag a view from the datasource window (creating a
dataGridView) that an update method is not added to the...
|
by: Miro |
last post by:
I will ask the question first then fumble thru trying to explain myself so i
dont waste too much of your time.
Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an
index - i...
|
by: travhale |
last post by:
in a new project using .net 2005, c#.
getting err message "Update requires a valid UpdateCommand when passed
DataRow collection with modified rows."
source RDBMS is oracle 8i. I add a new...
|
by: Irfan |
last post by:
hi,
I created a clickonce application and installed it in the client machine. As
expected a new shortcut is created in the Start->All Programs and i use
that to run the application.
When i...
|
by: Larry Hale |
last post by:
Thank you, again, Michael, for all your help many months ago.
I *FINALLY* got a HowTo done up; please see http://wiki.python.org/moin/HowTo/FileMagic
I've also emailed Mr. Hupp to see if he'll...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |