BlueStarBrite
Registered User.
- Local time
- Yesterday, 21:03
- Joined
- Jan 15, 2009
- Messages
- 23
Hi All,
I am new to the forum and new to Access as well. I have been lurking around and found this site to be a great assest so far so I decided to join.
Ok, so I was hoping someone could help me out here. I have 2 issues:
***Forgot to add I am using Access 2003 if that makes a difference***
(1) I found a great search option to use on my current form. In my Form header I have a text box and a search button. In my Detail section I have various controls (textboxes, combo boxes, etc.) Now what I want to do is lock all of the controls in my Detail section, but allow my Search box to still be enabled. I know that I need to use Ctl.Locked, but a little confused as to where. I tried using the suggestion in thread #: 163121 (sorry, cant post urls yet!), but I kept getting error messages.
(2) I have several fields which I need to set as Yes/No data types. However, on my form, there is only one checkbox. Or if I change the field to a combo box, I can only see one value (ex:yes) on the form. Then the strangest thing happens, once I click that value, I get displayed a -1. I understand this is how Access stores yes values, but why am I not seeing my No value and why when selecting is it not staying? (Hope that makes sense) -- Also, is there a way to store my Yes value as a 1 in my database instead of a -1 (I will need to import spreadsheets, and they will have a 1 for that value)
Thanks in advance!
Here is my code that I have so far on my form for the 1st issue:
************************
Private Sub cmdSearch_Click()
Dim strStudentRef As String
Dim strSearch As String
'Check txtSearch for Null value or Nill Entry first.
If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value", vbInformation, "Invalid Search Criteria!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------
'Performs the search using value entered into txtSearch
'and evaluates this against values in F1CORE_ID
DoCmd.ShowAllRecords
DoCmd.GoToControl ("F1CORE_ID")
DoCmd.FindRecord Me!txtSearch
F1CORE_ID.SetFocus
strStudentRef = F1CORE_ID.Text
txtSearch.SetFocus
strSearch = txtSearch.Text
'If matching record found sets focus in F1CORE_ID and shows msgbox
'and clears search control
If strStudentRef = strSearch Then
MsgBox "Match Found For: " & strSearch, vbInformation, "Search Successful!"
F1CORE_ID.SetFocus
txtSearch = ""
'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try Again!", vbInformation, "No Current Record in Database"
txtSearch.SetFocus
End If
End Sub
************************
I am new to the forum and new to Access as well. I have been lurking around and found this site to be a great assest so far so I decided to join.
Ok, so I was hoping someone could help me out here. I have 2 issues:
***Forgot to add I am using Access 2003 if that makes a difference***
(1) I found a great search option to use on my current form. In my Form header I have a text box and a search button. In my Detail section I have various controls (textboxes, combo boxes, etc.) Now what I want to do is lock all of the controls in my Detail section, but allow my Search box to still be enabled. I know that I need to use Ctl.Locked, but a little confused as to where. I tried using the suggestion in thread #: 163121 (sorry, cant post urls yet!), but I kept getting error messages.
(2) I have several fields which I need to set as Yes/No data types. However, on my form, there is only one checkbox. Or if I change the field to a combo box, I can only see one value (ex:yes) on the form. Then the strangest thing happens, once I click that value, I get displayed a -1. I understand this is how Access stores yes values, but why am I not seeing my No value and why when selecting is it not staying? (Hope that makes sense) -- Also, is there a way to store my Yes value as a 1 in my database instead of a -1 (I will need to import spreadsheets, and they will have a 1 for that value)
Thanks in advance!
Here is my code that I have so far on my form for the 1st issue:
************************
Private Sub cmdSearch_Click()
Dim strStudentRef As String
Dim strSearch As String
'Check txtSearch for Null value or Nill Entry first.
If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value", vbInformation, "Invalid Search Criteria!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------
'Performs the search using value entered into txtSearch
'and evaluates this against values in F1CORE_ID
DoCmd.ShowAllRecords
DoCmd.GoToControl ("F1CORE_ID")
DoCmd.FindRecord Me!txtSearch
F1CORE_ID.SetFocus
strStudentRef = F1CORE_ID.Text
txtSearch.SetFocus
strSearch = txtSearch.Text
'If matching record found sets focus in F1CORE_ID and shows msgbox
'and clears search control
If strStudentRef = strSearch Then
MsgBox "Match Found For: " & strSearch, vbInformation, "Search Successful!"
F1CORE_ID.SetFocus
txtSearch = ""
'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try Again!", vbInformation, "No Current Record in Database"
txtSearch.SetFocus
End If
End Sub
************************
Last edited: