Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 31st, 2005, 07:50 AM
ranbir singh ranbir singh is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 24 ranbir singh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 20 m 18 sec
Reputation Power: 0
two unbound box

i have created a form like

firstname ______ Last name _______
Add this record >>[command button with pic of arrow]
edit this record >>[command button with pic of arrow]

these two text boxes are not bounded to any table they are two text boxes

What i want is when the user type in the first name and the last name and presses the add this record, my form (candidate profile form) should show up with this name typed in (the name which i just typed) and

when the user presses the edit this record... the command button (arrow) should search for the record in the database and if no record exists, itshow record not found and if it finds any records which resembles the the same candidate profile form should show the appropraite record of the person i have typed in first name and the last name.

Reply With Quote
  #2  
Old January 31st, 2005, 04:02 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
For the command button Add:

Dim strFirstName As String, strLastName As String
Dim stDocName As String
stDocName = "candidate profile form"
If Not IsNull(txtFirstName) Then
strFirstName = txtFirstName.Value
End If
If Not IsNull(txtLastName) Then
strLastName = txtLastName.Value
End If

DoCmd.OpenForm stDocName, , , , acFormAdd

Forms![candidate profile form]![FirstName].Value = strFirstName
Forms![candidate profile form]![LastName].Value = strLastName

For the command button Edit:

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String
Dim strFirstName As String, strLastName As String
Dim stDocName As String
Dim i As Integer
stDocName = "candidate profile form"
If Not IsNull(txtFirstName) Then
strFirstName = txtFirstName.Value
End If
If Not IsNull(txtLastName) Then
strLastName = txtLastName.Value
End If

Set db = CurrentDb()
strSql = "SELECT NameOfTable.ID, NameOfTable.FirstName, NameOfTable.LastName " & _
"FROM NameOfTable " & _
"WHERE [NameOfTable].FirstName = '" & strFirstName & "'" & _
" AND [NameOfTable].LastName ='" & strLastName & "'"

Set rs = db.OpenRecordset(strSql, dbOpenSnapshot)

If rs.RecordCount <> 0 Then
With rs
i = rs!ID
End With
DoCmd.OpenForm stDocName, , , "[ID]= " & i
Else
strSql = "SELECT NameOfTable.ID, NameOfTable.FirstName, NameOfTable.LastName " & _
"FROM NameOfTable " & _
"WHERE [NameOfTable].FirstName Like'" & strFirstName & "*" & "'"

Set rs = db.OpenRecordset(strSql, dbOpenSnapshot)
If rs.RecordCount <> 0 Then
DoCmd.OpenForm stDocName, , , "[FirstName]Like'" & strFirstName & "*" & "'"
Else
strSql = "SELECT NameOfTable.ID, NameOfTable.FirstName, NameOfTable.LastName " & _
"FROM NameOfTable " & _
"WHERE [NameOfTable].LastName Like'" & strLastName & "*" & "'"
Set rs = db.OpenRecordset(strSql, dbOpenSnapshot)
If rs.RecordCount <> 0 Then
DoCmd.OpenForm stDocName, , , "[LastName]Like'" & strLastName & "*" & "'"
Else
MsgBox "There Are No Records That Match " & _
vbCrLf & vbTab & strFirstName & " " & strLastName
End If
End If
End If
db.Close

lwells

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > two unbound box


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT