Hi, I'm working on an Access 2007 database. I'm trying to build a search form that opens up your search on a query. I was working before, but I feel like i change something and now, it doesn't give me what I'm asking for. I have three fields on the form (companycell, companyflux, companyribbon). I don't know how to incorporate the value from companycell to the field on the query.
Any ideas? I'm knew at this and I'm getting frustrated because I can't find what is wrong with this.
Thanks before hand!
Code:
Private Sub Findbtm_Click()
If Me.CompanyCell.Value = "" Then
Beep
Select Case MsgBox("Cell Company is required", vbOK)
Case vbOK: 'do nothing
Case Else: 'do nothing
End Select
Else
If [Companyflux] = [company name] Or [CompanyRibbon] = [Company] Or [Companyflux] = "" Or [CompanyRibbon] = "" Then
DoCmd.OpenQuery "Sales"
Else
Beep
Select Case MsgBox("Combination not found. Would you like possible combinations?", vbYesNo)
Case vbYes: 'finds possible combinations
Beep
Select Case MsgBox("Would you like to make Flux unknown?", vbYesNo)
Case vbYes: 'Makes flux company unknown
Me.Companyflux.Value = ""
Me.newflux = Me.Companyflux
Me.newcell = Me.CompanyCell
Case vbNo: 'leaves flux company as it is
Me.newflux = Me.Companyflux
Me.newcell = Me.CompanyCell
Case Else: 'default case to trap any errors
'do nothing
End Select
Beep
Select Case MsgBox("Would you like to make Ribbon unknown?", vbYesNo)
Case vbYes: 'makes ribbon company unknown
Me.CompanyRibbon.Value = ""
Me.newribbon = Me.CompanyRibbon
Me.newcell = Me.CompanyCell
Case vbNo: 'leaves ribbon company as it is
Me.newribbon = Me.CompanyRibbon
Me.newcell = Me.CompanyCell
Case Else: 'defaul case to trab any errors
'do nothing
End Select
If [newflux] = [company name] Or [newribbon] = [Company] Or [newflux] = "" Or [newribbon] = "" Then
DoCmd.OpenQuery "Sales", acViewNormal
Else
Beep
Select Case MsgBox("Combination not found. Would you like to add a New Product?", vbYesNo)
Case vbYes: 'opens new product "entry form" and closes "sales" form
DoCmd.OpenForm "entry form"
DoCmd.Close acForm, "sales"
Case vbNo: 'closes "sales" form and goes to "main menu"
DoCmd.OpenForm "main menu"
DoCmd.Close acForm, "sales"
End Select
End If
Case vbNo:
'Do nothing
Case Else: 'Default case to trap any errors
'Do nothing
End Select
End If
End If
End Sub
Thanks before hand!
Comment